northlands/permuteseq
最新稳定版本:v0.2
Composer 安装命令:
composer require northlands/permuteseq
包简介
A small PHP library to obfuscate numbers.
README 文档
README
A small PHP library to obfuscate numbers. Use it when you don't want to expose your database numeric ids to users.
The permutations are collision-free and fully deterministic. The random-looking effect is due to encryption, not to a PRNG. The same boundary range with the same secret key will always produce the same output.
Installation
You can install the package via composer:
composer require northlands/permuteseq
Usage
$permuteseq = new Permuteseq(123456789012345, 1000, 9999); // Range 1000-9999 $encoded = $permuteseq->encode(1000); // 1446 $decoded = $permuteseq->decode($encoded); // 1000
Testing
composer test
In order to ensure compability with the Postgres extension, an integration test is included:
vendor/bin/pest --group=integration
The integration test requires a running Postgres database with the extension installed:
docker build -t postgres tests docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=local -d postgres psql> CREATE EXTENSION permuteseq;
Changelog
Please see CHANGELOG for more information on what has changed recently.
Disclaimer
The library should not be considered cryptographically strong or used to sensitive data.
Credits
-
https://github.com/dverite/permuteseq
The PostgreSQL extension by Daniel Vérité. -
https://czep.net/21/obfuscate.html
An article on how to obfuscate primary keys in databases.
Alternatives
-
https://github.com/ioleo/cryptomute
Another Format Preserving Encryption library supporting multiple ciphers (DES, AES and Camellia) but slower performance. -
https://github.com/vinkla/hashids
Generates YouTube-like ids from numbers. Can be limited to digit-alphabet, but returns strings like"09284"instead of safe integers. -
https://github.com/jenssegers/optimus
Super-fast number obfuscation based on Knuth's integer hash. However, range can only be defined by 4-62 bits.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 164
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-05