ict / 机密
轻松管理、编码和存储您的机密
v1.0.0
2023-05-20 11:26 UTC
Requires
- php: >=8.1
- ext-ctype: *
- ext-iconv: *
- symfony/console: 6.*
- symfony/dotenv: 6.*
- symfony/flex: ^2
- symfony/framework-bundle: 6.*
- symfony/runtime: 6.*
- symfony/yaml: 6.*
README
简介
此包允许开发者加密其密钥并使用redis作为保险库进行存储
要求
安装
使用composer安装
composer require ict/secrets:dev-main
配置
包需要以下配置
ict_secrets:
hash_alg: 'sha512' # Any type supported by php hash function
encoder: sodium
store:
type: redis
config:
uri: 'your redis uri connection'
目前,只允许使用sodium编码器和redis保险库。
如何使用
注入保险库服务
use Ict\Secrets\Vault\VaultStorageInterface; .......... public function __construct( private readonly VaultStorageInterface $vaultStorage )
存储一个密钥
$this->vaultStorage->storeKeys('your_encription_keys_name')->storeSecret('your_secret_name', 'your_secret_value');
your_encription_keys_name用于存储用于加密您的机密的加密密钥
检索一个密钥
$secretVal = $this->vaultStorage->getSecret($secretKey)
删除一个密钥
$secretVal = $this->vaultStorage->removeSecret($secretKey)