sivin/crypt
最新稳定版本:v2.1
Composer 安装命令:
composer require sivin/crypt
包简介
Small library for encryption via phpseclib
关键字:
README 文档
README
Small library for encryption via phpseclib
-
Install via composer
composer require sivin/crypt -
Register extension in
config.neon:extensions: crypt: SiViN\Crypt\DI\CryptExtension
-
Create or use your key/s:
/** @var Crypt */ private $crypt; public function __construct(Crypt $crypt) { $this->crypt = $crypt; } ... $keys = $this->crypt->createKeyPair() $privateKeyRaw = $keys['privateKeyRaw']; $publicKeyRaw = $keys['publicKeyRaw'];
-
Use your own key or define it in a
config.local.neon:$crypt->setPublicKey($myPublicKeyForEncrypt); $crypt->setPrivateKey($myPrivateKeyForDecrypt); //if there is a private key with a password $crypt->setPrivateKeyPassword($myPivateKeyPasswordForDecrypt);
or in a
config.local.neon:crypt: publicKeyPath: publicKeyFile.pub #for encrypting privateKeyPath: privateKeyFile.key #for decrypting privateKeyPassword: 'PrivateKeyPassword' #optional
If you only want to encrypt/decrypt, just define the encrypting/decrypting key
-
And finally?:
$encryptedStr = $crypt->encryptRijndaelMessage($stringToEncode); //for transport $decryptedStr = $crypt->decryptRijndaelMessage($encryptedStr); $encryptedStr = $crypt->encryptRsa($stringToEncode); $decryptedStr = $crypt->decryptRsa($encryptedStr); $encryptedStr = $crypt->encryptRijndael($stringToEncode); $decryptedStr = $crypt->decryptRijndael($encryptedStr);
统计信息
- 总下载量: 15.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-30