//DES 解密 加密 function encryptByDES(message, key) { var keyHex = CryptoJS.enc.Utf8.parse(key); var encrypted = CryptoJS.DES.encrypt(message, keyHex, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }); return encrypted.toString(); } //DES 解密 function decryptByDES(ciphertext, key) { var keyHex = CryptoJS.enc.Utf8.parse(key); // direct decrypt ciphertext var decrypted = CryptoJS.DES.decrypt({ ciphertext: CryptoJS.enc.Base64.parse(ciphertext) }, keyHex, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }); return decrypted.toString(CryptoJS.enc.Utf8); } function getEnclocal(param) { var val= localStorage.getItem(param); if(val!=null&&val!=undefined&&val!=""){ return JSON.parse(decryptByDES(val, "")); }else{ return val ; } } function setDeclocal(paramStr, param) { var val = param; if(val != null&&val!=undefined &&val !=""){ localStorage.setItem(paramStr, encryptByDES(JSON.stringify(param), "")); }else{ localStorage.setItem(paramStr,param); } }