const CryptoJS = require('crypto-js'); export function Encrypt(word, keyStr = '1234567891231231') { const key = CryptoJS.enc.Utf8.parse(keyStr); //十六位十六进制数作为密钥 const iv = CryptoJS.enc.Utf8.parse(keyStr); //十六位十六进制数作为密钥偏移量 const srcs = CryptoJS.enc.Utf8.parse(word); var encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); return CryptoJS.enc.Base64.stringify(encrypted.ciphertext).replace(/\s/g, '') }