CryptoJS前端加密后端php 解密

CryptoJS前端加密后端php 解密

猿掌柜
2022-07-22 / 0 评论 / 24 阅读 / 正在检测是否收录...

前端加密

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;
}
1

评论 (0)

取消