<?php
//php7.1中屏蔽错误 mcrypt_decrypt还能继续使用说明没有移除
error_reporting(0);
//aes的解密方案1
$miwen1 = "F6D6F143A7ACBCF0FCFCF542C638836C4AEA9BC33B9A5CE867A5102E0770F62D8D76EFBE1EF023790D48058EDACF5847D5864A3331FE0F0E4BA1B81B774EB294";
$key1 = 'OKLU520XJB09906H'; //秘钥
$iv1 = $key1;
$decrypted1 = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key1, hex2bin($miwen1), MCRYPT_MODE_CBC, $iv1); //秘钥解密
//处理json
$json_str1 = str_replace("\u0000", "", json_encode($decrypted1));
$arr1 = json_decode(json_decode($json_str1), true);
//获取账号密码
print_r($arr1);
$miwen2 = "F6D6F143A7ACBCF0FCFCF542C638836C4AEA9BC33B9A5CE867A5102E0770F62D8D76EFBE1EF023790D48058EDACF5847D5864A3331FE0F0E4BA1B81B774EB294";
$key2 = "OKLU520XJB09906H";
$iv2 = $key2;
//OpenSSL 解密 或者OPENSSL_NO_PADDING
$decrypted2 = openssl_decrypt(hex2bin($miwen2), "aes-128-cbc", $key2, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv2);
//echo json_encode($de_data);
//有特殊字符再json_encode之后能否发现,然后过滤掉"[{\"T\":\"638107685499086584\",\"P\":\"OT4pQ42TiE6jDPy6\",\"N\":\"wd_wd\"}]\u0000"
$json_str2 = str_replace("\u0000", "", json_encode($decrypted2));
$arr2 = json_decode(json_decode($json_str2), true);
print_r($arr2);
//aes加密方案1 mcrypt_encrypt 超过7.1舍弃了就,php7.1屏蔽错误还可以用
$mingwen3 = "你好";
$key3 = 'OKLU520XJB09906H';
$iv3 = $key3;
$encrypted3 = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key3, $mingwen3, MCRYPT_MODE_CBC, $iv3);
$miwen3 = base64_encode($encrypted3);
echo $miwen3;
//代替方案 openssl_encrypt 方式更通用
$key4 = "OKLU520XJB09906H";
$iv4 = $key4;
$mingwen4 = "你好";
if (strlen($mingwen4) % 16) {
$mingwen4 = str_pad($mingwen4, strlen($mingwen4) + 16 - strlen($mingwen4) % 16, "\0");
}
$encrypted4 = openssl_encrypt($mingwen4, 'AES-128-CBC', $key4, OPENSSL_NO_PADDING, $iv4);
$miwen4 = base64_encode($encrypted4);
echo $miwen4;
//aes解密方案2
$miwen33 = "fyy6UkIa/PXyXxR5vm316w=="; //你好
$key33 = 'OKLU520XJB09906H';
$iv33 = $key33;
$plain_str33 = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key33, base64_decode($miwen33), MCRYPT_MODE_CBC, $iv33);
$plain_str33 = str_replace(array("\r\n", "\r", "\n", "\0"), "", $plain_str33);
echo json_encode($plain_str33);
$miwen44 = "fyy6UkIa/PXyXxR5vm316w=="; //你好
$key44 = "OKLU520XJB09906H";
$iv44 = $key44;
//OpenSSL 解密 或者OPENSSL_NO_PADDING
$plain_str44 = openssl_decrypt(base64_decode($miwen44), "aes-128-cbc", $key44, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv44);
$plain_str44 = str_replace(array("\r\n", "\r", "\n", "\0"), "", $plain_str44);
echo json_encode($plain_str44);