前端加密
jm(word){
var key = CryptoJS.enc.Latin1.parse('B55BA55A12ABCDEF'); //为了避免补位,直接用16位的秘钥
var iv = CryptoJS.enc.Latin1.parse('ABCDEF123A55A412'); //16位初始向量
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(word, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
return encrypted.toString();
},
后端解密
function decuserId($str){
$key = "B55BA55A12ABCDEF";
$iv = "ABCDEF123A55A412";
$decrypted = openssl_decrypt(base64_decode($str), 'AES-128-CBC', $key, 1, $iv);
return $decrypted;
}
评论 (0)