加密重要資訊,如用戶名、密碼,防止http攔截,瀏覽器使用公鑰加密,服務器端使用私鑰解密
頁面添加參考: jsencrypt.min.js
// 3-Url引數加密類 if (window.JSEncrypt) { function InitJSEncrypt() { var _this = this; var encrypt; _this.init = function () { encrypt = new window.JSEncrypt(); encrypt.setPublicKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');//替換公鑰 }; _this.getEncrypt = function () { if (encrypt == null) { _this.init(); } return encrypt; }; }; $.extend(window.JSEncrypt, new InitJSEncrypt().getEncrypt()); }
//加密用戶名密碼
var encryptedEmail = window.JSEncrypt.encrypt(email); var encryptedPass = window.JSEncrypt.encrypt(password);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/169023.html
標籤:JavaScript
上一篇:JS基礎語法---陣列
