吉安感知网项目-前端
罗广辉
2026-01-26 beb95fb5fc166804056abafd70fc01ac27de7621
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
 * 密码解密
 */
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);
}