function decrypt($encryptedData, $key,$iv) {
$decryptedData = openssl_decrypt(
base64_decode($encryptedData),
'AES-128-CBC',
$key,
OPENSSL_RAW_DATA,
$iv
);
if ($decryptedData === false) {
echo 'failed';
}
return $decryptedData;
}
vuejs方法
export function encryptionValue(value, key = 'E7D9B13077291073041EE0AD54EAD975', iv = '0000000000000000') {
value = value.toString()
key = CryptoJS.enc.Utf8.parse(key)
iv = CryptoJS.enc.Utf8.parse(iv)
const encrypted = CryptoJS.AES.encrypt(value, key, { iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
return encrypted.toString()
}