RSA encryption front-end JS encryption, back-end ASP.
Reference: http://www.ohdave.com/rsa/'s JS Encryption library
Front-end JS encryption code:
{ debugger; var pwdstr = document.getElementById ("Txtpasswordstr"). Value; var uidstr= $ ("#<%=txtuserstr.clientid%>"). Val (); if (!pwdstr | | pwdstr.length = = 0 | |!uidstr | | uidstr.length==0) { return false; } var keye = "<%=PubRsaKeyE%>"; var Keym = "<%=PubRsaKeyM%>"; Setmaxdigits (131); var key = new Rsakeypair (Keye, "", Keym); var pwdrtn = encryptedstring (key, pwdstr); var uidrtn = encryptedstring (key, uidstr); $ ("#<%=txtpassword.clientid%>"). Val (PWDRTN); $ ("#<%=txtuser.clientid%>"). Val (UIDRTN);}
Background Decryption Code:
Try { rsacryptoserviceprovider RSA = (RSACryptoServiceProvider) cache.get ("Privatekey"); Byte[] result = RSA. Decrypt (hexstringtobytes (password), false); Password = Encoding.UTF8.GetString (result); result = RSA. Decrypt (Hexstringtobytes (UserName), false); UserName = Encoding.UTF8.GetString (result); } catch (Exception ex) { showmessage ("Authentication failed! "," The account or password you logged in is wrong! "," "); return; }
A "parameter error" exception is reported in some development environments. However, the other project or server environment is normal.
No reason found, unknown principle Ah!!
Just make a record of it.
RSA encryption front-end JS encryption, back-end ASP.