qbonaventure / inner-cryptography
简单的加密服务
dev-master
2016-11-19 21:27 UTC
Requires
- php: ^5.3 || ^7.0
This package is not auto-updated.
Last update: 2024-09-14 18:47:41 UTC
README
简介
此服务提供加密/解密数据的方法,既可以简单地进行,也可以使用更强的哈希比较。
需求
- Zend Framework 2 (最新master版本)
安装
主要设置
通过克隆项目(不推荐)
- 将此项目克隆到您的
./vendor/
目录中。
使用composer
```json
"require": {
// ...
"qbonaventure/Inner-Cryptography": "dev-master"
}
"autoload": {
"psr-4": {// ...
"QBonaventure\\InnerCryptography\\": "vendor/qbonaventure/inner-cryptography/src/"
}
}
```
安装后
-
在您的
{application|module}.config.php
文件中启用它。<?php return array( // ... 'service_manager' => array( 'factories' => array( // ... 'CryptographyInterface' => 'QBonaventure\InnerCryptography\ServiceFactory', ), ), // ... );
-
将 config/cryptography.global.php.dist 复制到您的配置目录
-
从这些文件中删除 .dist 扩展名并填写空白(见“配置”)
配置
```php
<?php
return array(
'cryptography' => array(
'key' => '',
'iv' => '',
'method' => 'aes-512-cbc',
'hashAlgo' => 'sha256',
'hashCost' => null,
),
);
```
- "key" 必须是一串随机的字母和数字的长字符串,如 200+ 个字符
- "iv" 是一个可以由大约 20 个随机字母和数字组成的向量
- "method" 是加密方法,默认为 "aes-512-cbc"
- "hashAlgo" 是加密中使用的哈希算法,默认为 "sha256"
- "hashCost" 是 password_hash() 的哈希函数成本。默认为 "null",即函数的默认值:10