import CryptoJS from 'crypto-js'

const SECRET_KEY = CryptoJS.enc.Utf8.parse('KeyWareSecretKey');


// 加密
export function encrypt(data) {
    const encrypted = CryptoJS.AES.encrypt(data, SECRET_KEY, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}

// 解密
export function decrypt(data) {
    const decrypted = CryptoJS.AES.decrypt(data, SECRET_KEY, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    })
    return decrypted.toString(CryptoJS.enc.Utf8)
}