Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
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 31-Jan-13 1:46am
Comments
Ankur\m/ at 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
good
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.
  Permalink  
Comments
Venkat_C6 at 31-Jan-13 7:08am
   
Ok.. Thankyou..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
<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);
}
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 299
1 Maciej Los 295
2 Sergey Alexandrovich Kryukov 205
3 Aajmot Sk 202
4 Sinisa Hajnal 166
0 OriginalGriff 7,760
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,785


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2014
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