标签:https key ups code hub dir 密钥 LEDE jquery
1、下载crypto.js文件库
https://github.com/brix/crypto-js/releases
2、引入文件
<script type="text/javascript" src="js/jquery.min.js"></script> <script src="js/rollups/tripledes.js"></script> <script src="js/components/mode-ecb.js"></script>
3、加解密
//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); }
4、前后端协商密钥进行开发
标签:https key ups code hub dir 密钥 LEDE jquery
原文地址:https://www.cnblogs.com/gopark/p/10478612.html