osw3 / symfony-entity-encrypt
在数据库中加密和解密实体数据。
0.0.2
2024-09-18 00:33 UTC
This package is auto-updated.
Last update: 2024-09-18 00:33:53 UTC
README
在数据库中加密和解密实体数据
如何安装
步骤 1:下载 Bundle
打开命令行,进入您的项目目录,并执行以下命令以下载此 Bundle 的最新稳定版本
composer require osw3/symfony-entity-encrypt
步骤 2:启用 Bundle
然后,通过将其添加到项目中 config/bundles.php 文件中注册的 Bundle 列表来启用此 Bundle
// config/bundles.php return [ // ... OSW3\EntityEncrypt\EntityEncryptBundle::class => ['all' => true], ];
如何使用
步骤 1:编辑配置
编辑配置文件 config/packages/entity_encrypt.yaml
entity_encrypt: algo: aes256
步骤 2:将 Encrypted 属性添加到您的实体中
use OSW3\EntityEncrypt\Attribute\Encrypted; class Message { // ... #[ORM\Column(type: Types::TEXT)] #[Encrypted] // Just add this Attribute private ?string $secret = null; // ... }