初始化代码

This commit is contained in:
2025-08-11 10:22:05 +08:00
commit ebd8d85201
4206 changed files with 753018 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
namespace app\common\yun\util;
class DesUtil
{
/**
* 密钥向量
* @var string
*/
private $des3key;
/**
* 混淆向量
* @var string|null
*/
private $iv;
/**
* 构造传递⼆个已经进⾏base64_encode的KEY与IV
*
* @param string $des3key
* @param string $iv
*/
function __construct($des3key, $iv = null)
{
$this->des3key = $des3key;
$this->iv = $iv;
}
/**
* 加密
* @param <type> $value
* @return <type>
*/
public function encrypt($value)
{
$iv = substr($this->des3key, 0, 8);
$ret = openssl_encrypt($value, 'DES-EDE3-CBC', $this->des3key, 0, $iv);
if (false === $ret) {
return openssl_error_string();
}
return $ret;
}
/**
* 解密
* @param <type> $value
* @return <type>
*/
public function decrypt($value)
{
$iv = substr($this->des3key, 0, 8);
$ret = openssl_decrypt($value, 'DES-EDE3-CBC', $this->des3key, 0, $iv);
if (false === $ret) {
return openssl_error_string();
}
return $ret;
}
}