loostro/cryptomute
最新稳定版本:v1.0.3
Composer 安装命令:
composer require loostro/cryptomute
包简介
Encrypt numeric data (binary, decimal, hex) preserving it's format (eg. 16-digits card number to 16-digits encrypted number).
README 文档
README
A small PHP class implementing Format Preserving Encryption via Feistel Network.
1. Installation
You can install Cryptomute via Composer (packagist has loostro/cryptomute package). In your composer.json file use:
{
"require": {
"loostro/cryptomute": "^1.0"
}
}
And run: php composer.phar install. After that you can require the autoloader and use Cryptomute:
2. Usage
require_once 'vendor/autoload.php'; use Cryptomute\Cryptomute; $cryptomute = new Cryptomute( 'aes-128-cbc', // cipher '0123456789zxcvbn', // base key 7, // number of rounds ); $password = '0123456789qwerty'; $iv = '0123456789abcdef'; $plainValue = '2048'; $encoded = $cryptomute->encrypt($plainValue, 10, false, $password, $iv); $decoded = $cryptomute->decrypt($encoded, 10, false, $password, $iv); var_dump([ 'plainValue' => $plainValue, 'encoded' => $encoded, 'decoded' => $decoded, ]);
array(3) {
["plainValue"]=>
string(4) "2048"
["encoded"]=>
string(9) "309034283"
["decoded"]=>
string(4) "2048"
}
3. Options
3.1 Cipher
Cipher is the first constructor argument. Supported cipher methods are:
| Cipher | IV |
|---|---|
des-cbc |
yes |
aes-128-cbc |
yes |
aes-128-ecb |
no |
aes-192-cbc |
yes |
aes-192-ecb |
no |
camellia-128-cbc |
yes |
camellia-128-ecb |
no |
camellia-192-cbc |
yes |
camellia-192-ecb |
no |
3.2 Key
Key is the second constructor argument. Base key from which all round keys are derrived.
3.3 Rounds
Rounds is the third constructor argument. Must be an odd integer greater or equal to 3. More rounds is more secure, but also slower. Recommended value is at least 7.
4. Public methods
4.1 setValueRange($minValue, $maxValue)
Sets minimum and maximum values. If the result is out of range it will be re-encrypted (or re-decrypted) until ouput is in range.
4.2 encrypt($plainValue, $base, $pad, $password, $iv)
Encrypts data. Takes following arguments:
$plainValue(string) input data to be encrypted$base(int) input data base, accepted values is 2 (binary), 10 (decimal) or 16 (hexadecimal)$pad(bool) pad left output to match$maxValue's length?$password(string) encryption password$iv(string) initialization vector - only if cipher requires it
4.2 decrypt($cryptValue, $base, $pad, $password, $iv)
Decrypts data. Takes following arguments:
$cryptValue(string) input data to be decrypted$base(int) input data base, accepted values is 2 (binary), 10 (decimal) or 16 (hexadecimal)$pad(bool) pad left output to match$maxValue's length?$password(string) encryption password$iv(string) initialization vector - only if cipher requires it
License
Cryptomute is licensed under The MIT License (MIT).
loostro/cryptomute 适用场景与选型建议
loostro/cryptomute 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27.25k 次下载、GitHub Stars 达 25, 最近一次更新时间为 2016 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「encode」 「decode」 「encrypt」 「decrypt」 「obfuscate」 「cryptomute」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 loostro/cryptomute 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 loostro/cryptomute 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 loostro/cryptomute 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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.
Encode integer IDs using a preset or customized symbol set
Encrypted symfony entity's by verified and standardized libraries
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Runn Me! Serialization Library
♺ Laravel Nova Hashids card. Convert your ids.
统计信息
- 总下载量: 27.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 25
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-15