/** * 密码解密 */ import CryptoJS from 'crypto-js'; // 256-bit key const key = 'a12345678901234r5678901234567890' // 16-byte IV const iv = '9185367198901234' /** * mqtt 密码解密方法 * @param {*} data * @returns */ export function decryptAES(data) { const secretKey = CryptoJS.enc.Utf8.parse(key); const ivParse = CryptoJS.enc.Utf8.parse(iv); const decrypted = CryptoJS.AES.decrypt({ ciphertext: CryptoJS.enc.Base64.parse(data) }, secretKey, { iv: ivParse, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); return decrypted.toString(CryptoJS.enc.Utf8); }