socfest/encrypted-types
Composer 安装命令:
composer require socfest/encrypted-types
包简介
README 文档
README
Store database data encrypted
Encryption methods:
- base64
- openssl
Install
Require package via composer
composer require socfest/encrypted-types
Init bundle in bundles.php
# config/bundles.php
return [
// for ODM
Socfest\MongoDB\SocfestMongoEncryptedTypesBundle::class => ['all' => true],
//for ORM
Socfest\ORM\SocfestORMEncryptedTypesBundle::class => ['all' => true],
]
You can specify the openssl cipher method by enter this to .env file.
See the php.net openssl_cipher_iv_length page (https://www.php.net/manual/en/function.openssl-cipher-iv-length.php)
OPENSSL_CIPHER=%cipher_method%
Usage
ODM
In the model you can specify the field type. The new encrypted types are:
- encrypted_openssl
- encrypted_base64
/**
* @var string
* @MongoDB\Field(type="encrypted_openssl")
*/
protected $fullName;
In query you can find by full value, and you have to encrypt before set to equals.
Don't forget to use the correct encrypter!
$this->dm->getRepository(User::class)
->createQueryBuilder()
->field('fullName')
->equals(OpenSSLEncrypter::encrypt('X Y'))
->getQuery()
->execure()
);
also work with find methods
$this->dm->getRepository(User::class)
->findOneBy([
'fullName' => OpenSSLEncrypter::encrypt('X Y')
])
统计信息
- 总下载量: 206
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-21