//RSA签名排列,按键值字母排序
public function encryptRsaStr($param)
{
//参数排序
ksort($param);
unset($param['notify_url']);
unset($param['async_notify_url']);
return urldecode(http_build_query($param));
}
//AES加密排列,按键值字母排序
function encryptAesStr($param)
{
//参数排序
ksort($param);
return json_encode($param,true);
}
//AES-128-ECB加密
function aes_encrypt($data, $key) {
$data = openssl_encrypt($data, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
return base64_encode($data);
}
//AES-128-ECB解密
function aes_decrypt($data, $key) {
$encrypted = base64_decode($data);
return openssl_decrypt($encrypted, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
}
//公钥加密
public function PublicEncrypt($data){
//openssl_public_encrypt($data,$encrypted,$this->pu_key);/ /公钥加密
$crypto = '';
foreach (str_split($data, 117) as $chunk) {
openssl_public_encrypt($chunk, $encryptData, $this-&
php加密方式:AES-128-ECB
最新推荐文章于 2024-05-21 21:13:36 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)