Reputation: 30867
I want to encrypt some text in URL with a simple java-script algorithm and then decrypt it at code behind of an ASP.NET page using C#.
ROT13
is a good choice but unfortunately I cannot use it due to some confidential details. Anything like that would help but I don't know the famous ones. Security is not a matter at all, just twisting the string in some way and retrieve it later.
Upvotes: 2
Views: 6030
Reputation: 1116
Caesar cipher is a quite simple method for encrypting a text. Or you could simply encode the text in BASE64, which also makes it hard to read for humans. BASE64 naturally offers no security at all, but you can use standard libraries for encoding and decoding.
Upvotes: 0
Reputation: 7093
If you are looking for RSA (assymentric encryption) the you can use jsbn http://www-cs-students.stanford.edu/~tjw/jsbn/ javascript library for client side and the standard .Net RSACryptoServiceProvider for server side.
They do cooperate perfectly between each other.
I hope this helps!
Upvotes: 1
Reputation: 192607
Javascript and C# both support a number of different "real" encryption algorithms.
check out Javascript DES and 3DES
Question: Triple DES decryption in classic ASP?
example: http://jsbin.com/oguye3
source: http://cheeso.members.winisp.net/srcview.aspx?dir=DES
DES has known weaknesses, but that library also supports 3DES, which is stronger.
Also check out Javascript and AES
Getting SlowAES and RijndaelManaged class in .NET to play together
Here's a working demo of AES in the browser:
http://jsbin.com/itiye5/3
Upvotes: 1
Reputation: 532625
Who are you trying to hide it from? The end-user or someone listening on the wire? Given that anyone can use a browser-based debugger and inspect variables at run time, it doesn't really make much sense to rely on encryption to hide the information from the end-user (unless you encrypt it before you send it to the client and don't decrypt it until it's been sent back). If you're trying to hide the information on the wire, using SSL is definitely the way to go.
Upvotes: 3