@fast-china/utils
Version:
Fast 工具库.
3 lines (2 loc) • 962 B
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("crypto-js"),t=require("../console/index.js"),n={aes:{encrypt:(t,n,r,s=e.mode.CBC)=>t?(n.length<32&&(n=n.padEnd(32,"f")),n.length>32&&(n=n.substring(0,32)),r.length<16&&(r=r.padEnd(16,"f")),r.length>16&&(r=r.substring(0,16)),e.AES.encrypt(t,e.enc.Utf8.parse(n),{iv:e.enc.Utf8.parse(r),mode:s}).toString()):t,decrypt(n,r,s,o=e.mode.CBC){if(!n)return null;r.length<32&&(r=r.padEnd(32,"f")),r.length>32&&(r=r.substring(0,32)),s.length<16&&(s=s.padEnd(16,"f")),s.length>16&&(s=s.substring(0,16));const p=e.AES.decrypt(n,e.enc.Utf8.parse(r),{iv:e.enc.Utf8.parse(s),mode:o});try{const t=p.toString(e.enc.Utf8);return JSON.parse(t)}catch(c){return t.consoleError("AESCrypto",c),null}}},sha1:{encrypt:t=>t?e.SHA1(t).toString(e.enc.Hex).toUpperCase():t},MD5:{encrypt:t=>t?e.MD5(t).toString(e.enc.Hex).toUpperCase():t}};exports.cryptoUtil=n;
//# sourceMappingURL=index.js.map