RSA encryption front-end JS encryption, back-end ASP.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.