ict/机密

轻松管理、编码和存储您的机密

安装: 6

依赖项: 0

建议者: 0

安全: 0

星标: 2

关注者: 1

分支: 0

公开问题: 0

类型:symfony-bundle

v1.0.0 2023-05-20 11:26 UTC

This package is auto-updated.

Last update: 2024-09-19 15:56:14 UTC


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)