JS can be used to encrypt the foreground data to prevent malicious access, the following code, with Base64 data encryption, can be decrypted in the background.
Introduction of JS
<script type= "Text/javascript" src= "jquery.min.js" ></script><script type= "Text/javascript" src= " Jquery.base64.js "></script>
The data in the HTML
Name:<inputtype= "text"ID= "Name" ><BR/>Password:<inputtype= "Password"ID= "Password" ><BR/><Buttononclick= "SubmitData ()">Submit</Button>
JS Processing
<script>functionSubmitData () {varobj =NewObject (); Obj.name= $ (' #name '). Val (); Obj.password= $ (' #password '). Val (); //converted to JSON after encryptionvarstr =$.base64.encode (json.stringify (obj)); $.post ("Your URL address", {data:str},function(data) {Console.log (data); }); } //extended base64, support ChineseJquery.base64 = (function($) { //Private Property varKeystr = "Abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/="; //Private method for UTF-8 encoding functionUtf8encode (String) {string= String.Replace (/\r\n/g, "\ n"); varUtftext = ""; for(varn = 0; n < string.length; n++) { varc =string.charcodeat (n); if(C < 128) {Utftext+=String.fromCharCode (c); } Else if((C > 127) && (C < 2048) ) {Utftext+ = String.fromCharCode ((c >> 6) | 192); Utftext+ = String.fromCharCode ((C & 63) | 128); } Else{Utftext+ = String.fromCharCode ((c >> 12) | 224); Utftext+ = String.fromCharCode (((c >> 6) & 63) | 128); Utftext+ = String.fromCharCode ((C & 63) | 128); } } returnUtftext; } functionencode (input) {varOutput = ""; varchr1, CHR2, CHR3, Enc1, Enc2, enc3, Enc4; vari = 0; Input=Utf8encode (input); while(I <input.length) {chr1= Input.charcodeat (i++); CHR2= Input.charcodeat (i++); CHR3= Input.charcodeat (i++); Enc1= Chr1 >> 2; ENC2= ((Chr1 & 3) << 4) | (CHR2 >> 4); Enc3= ((CHR2 &) << 2) | (CHR3 >> 6); Enc4= CHR3 & 63; if(IsNaN (CHR2)) {enc3= ENC4 = 64; } Else if(IsNaN (CHR3)) {Enc4= 64; } Output= output +Keystr.charat (ENC1)+ Keystr.charat (ENC2) +Keystr.charat (enc3)+Keystr.charat (ENC4); } returnoutput; } return{encode:function(str) {returnencode (str); } }; } (JQuery)); </script>
Using JS to encrypt form forms base64