Click here to Skip to main content
13,142,182 members (54,358 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Dear All,

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

Posted 31-Jan-13 0:46am
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Venkat_C6 31-Jan-13 7:08am
Ok.. Thankyou..
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

first u have to download[^]

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

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

JavaScript Function
function LoginClicked() {
            var pass = document.getElementById('<%=txtPassword.ClientID%>');
var md5encypt = hex_md5(pass.value);

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100