Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All,

Iam encrypting value and storing it in a Cookie in Asp.net. Iam accessing the cookie in Javascript. Now Iam not getting how to decrypt that value in Javascript. Can anybody help plz??

Thanks..
Posted
Comments
Ankur\m/ 31-Jan-13 6:51am    
To know how to decrypt a value, you must know which encryption method you used or how you encrypted it.

Getting encryption algorithms from technology to technology to encrypt and decrypt in the same way is notoriously difficult.

Also, if you're decrypting the cookie in JS then you must be rendering the decryption key into the page response.

This is not secure and as such negates the point of encrypting the data in the cookie in the first place.

My advice would be to use the ASP.Net engine to decrypt the value.

You can read the cookie using JS, if you'd prefer, and then pass the data via AJAX or a postback to the ASP.Net engine or you can read the cookie from the HttpRequest object as part of the request. Then use ASP.Net to do the decryption and provide the data.

This way you don't have to expose your keys to the client.

With modern browsers very little in your page response is secure. All browsers have development tool sets which allow you to interrogate the page response and the scripts being run by the page.
 
Share this answer
 
Comments
Venkat_C6 31-Jan-13 7:08am    
Ok.. Thankyou..
first u have to download
http://code.google.com/p/sail-web/source/browse/branches/vlewrapper-2.0/WebContent/vle/sound/md5_old.js?r=1815[^]

use it in page like
HTML
<script type="text/javascript" language="javascript" src="js/md5_old.js"></script>


HTML
<input type="button" style="border: 1px;" value="Log In"  önclick="LoginClicked()" />


JavaScript Function
HTML
function LoginClicked() {

            var pass = document.getElementById('<%=txtPassword.ClientID%>');
var md5encypt = hex_md5(pass.value);
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900