icfg-aes.js 571 Bytes
const CryptoJS = require('../vendors/crypto-js/index');
const key = CryptoJS.enc.Utf8.parse('yoho9646YOHO9646');
const iv = CryptoJS.enc.Utf8.parse('YOHO9646yoho9646');

//加密方法
function encrypt(word) {
    word = CryptoJS.enc.Utf8.parse(word);
    let encrypted = CryptoJS.AES.encrypt(word, key, {iv});
    return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
}

//解密方法
function decrypt(word) {
    let decrypted = CryptoJS.AES.decrypt(word, key, {iv});
    return CryptoJS.enc.Utf8.stringify(decrypted);
}
    
export {
    encrypt,
    decrypt
};