Sunday, May 12, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
107
rated 0 times [  112] [ 5]  / answers: 1 / hits: 26045  / 15 Years ago, tue, april 14, 2009, 12:00:00

I'm developing an ASP.NET MVC application in which I want to encrypt a short string on the server, using C#, and send it to the client-side.



Then on the client-side it will be decrypted through Javascript code.



Any thoughts on how to implement this?



Do you know of a simple encryption algorithm (doesn't have to be bullet-proof secure) that can be easily translated from C# to Javascript or vice-versa?



NOTE: I could do this entirely in C# and do the decryption through Ajax, but I'd prefer not to do it this way, as I want to reduce website traffic as much as possible.


More From » c#

 Answers
235

The System.Security.Cryptography has a bunch of symetric (and asymetric) encrytion algorithms ready to use. (For something super secure use aes)



You should be able to find matching Javascript implementation for most (here are a few aes implementations in JS)





Note: If you are planning to use private key based encryption then keep in mind, your web page is going to have the key embedded in it and that means that it all becomes kind of pointless cause anyone with access to the page can do the decryption, at best you would be making the life of the screen scrapers a little bit harder. If making screen scrapers life harder is your goal you could just use an obsfucation algorithm. Any trivial implementation would make very impractical for screen scrapers that do not have a javascript engine:



Eg.



function samObsfucated()
{
return(s + a + m + @ + s + . + com);
}


Then onload populate your email fields with the output of these functions.



Javascript encryption has a really good use case for software that stores passwords for users ala clipperz


[#99711] Monday, April 6, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myakylas

Total Points: 66
Total Questions: 85
Total Answers: 95

Location: Guadeloupe
Member since Sat, Aug 22, 2020
4 Years ago
myakylas questions
Thu, Apr 28, 22, 00:00, 2 Years ago
Thu, Apr 8, 21, 00:00, 3 Years ago
Sat, Sep 19, 20, 00:00, 4 Years ago
;