// 加解密方法 import CryptoJS from 'crypto-js' // const key = 'zhst@bonus@zhst@bonus@1234567890' // 加密密钥 const key = 'jjbns@jysoft1088' // 加密密钥 const utf8Key = CryptoJS.enc.Utf8.parse(key) // AES 加密(UTF-8 处理) export const encrypt = (message) => { const utf8Message = CryptoJS.enc.Utf8.parse(message) const encrypted = CryptoJS.AES.encrypt(utf8Message, utf8Key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, }) return encrypted.toString() } // AES 解密 export const decrypt = (encryptedBase64) => { try { const decrypted = CryptoJS.AES.decrypt(encryptedBase64, utf8Key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, }) return JSON.parse(CryptoJS.enc.Utf8.stringify(decrypted)) } catch (error) { return encryptedBase64 } }