这是javascript中的代码,出于某种原因,我无法在PHP中重新编码
function encrypt(b, a) {
var c = CryptoJS.MD5(CryptoJS.enc.Utf8.parse(a));
return CryptoJS.AES.encrypt(b, c, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
}).toString()
}
更新: 我试过这个,但输出结果不一样: PHP
$key = md5('SR0.08963341827756699');
$key_size = strlen($key);
$plaintext = "22222222";
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key,
$plaintext, MCRYPT_MODE_ECB, $iv);
echo base64_encode($ciphertext);
的JavaScript
输入:encrypt('22222222', 'SR0.08963341827756699')
输出:RnN1WTGkZ9RKPQz3eBtivQ==
PHP
输入:字符串= 22222222
,密钥= SR0.08963341827756699
输出:ZA2pbDiSx3chj9/ubbUfOA==