This commit is contained in:
2025-09-13 01:22:15 +08:00
parent 155e05fd6d
commit 1a4b8551a0
674 changed files with 146276 additions and 0 deletions

View File

@ -0,0 +1,48 @@
<?php
/**
*
* @authorllbjj
* @DateTime2022/5/5 18:20
* @Description
*
*/
namespace Application\Common;
use Laminas\Crypt\BlockCipher;
use Laminas\Crypt\Key\Derivation\Pbkdf2;
use Laminas\Crypt\Key\Derivation\Scrypt;
use Laminas\Crypt\Password\Bcrypt;
use Laminas\Crypt\Password\BcryptSha;
use Laminas\Math\Rand;
class Crypt
{
/**
* Notes: 对称加解密 使用例子Crypt::blockCipher()->encrypt($data) Crypt::blockCipher()->decrypt($data)
* User: llbjj
* DateTime: 2022/5/5 18:48
*
* @return BlockCipher
*/
static function blockCipher() {
$blockCipher = BlockCipher::factory('openssl', ['algo' => 'aes', 'mode' => 'gcm']);
$blockCipher->setKey('ae60e54db83a30ea985fcd77b14c063320922864a584c5dfb96e77d84e7317aa');
return $blockCipher;
}
/**
* Notes: 获取加密字符串
* User: llbjj
* DateTime: 2022/5/5 19:12
*
* @param string $data
* @return string
*/
static function createKey(string $data = 'YikeenEDC') {
$salt = Rand::getBytes(32, true);
$key = Scrypt::calc($data, $salt, 2048, 3, 1, 32);
return bin2hex($key);
}
}