// crypt-helper.js // CryptoJS 已经由 cdn 引入,可直接使用 (function () { class CryptToJS { constructor() { this.crypt = CryptoJS; this.secret = 'Believe in yourself.'; } Encrypt(text) { return this.crypt.AES.encrypt(text, this.secret).toString(); } Decrypt(text) { if (!text) return ""; return this.crypt.AES.decrypt(text, this.secret).toString(this.crypt.enc.Utf8); } } // 关键:挂载到 window window.CryptToJS = new CryptToJS(); })();