northlands/permuteseq
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.
northlands/permuteseq 适用场景与选型建议
northlands/permuteseq 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 164 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 09 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「permutation」 「obfuscation」 「fiestel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 northlands/permuteseq 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 northlands/permuteseq 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 northlands/permuteseq 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Hoa\Math library.
Math libraries for Combinatorics (Combinations, Permutations, ...).
Simple captcha generator
AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.
Laravel package for obfuscating ids in urls.
Seo text generator library for Symfony 5
统计信息
- 总下载量: 164
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-05