简体   繁体   English

使用Javascript加密和使用C#解密的简单算法

[英]Simple algorithm for encrypting with Javascript and decrypting with C#

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#. 我想使用简单的Java脚本算法对URL中的一些文本进行加密,然后使用C#在ASP.NET页面后面的代码中对其进行解密。

ROT13 is a good choice but unfortunately I cannot use it due to some confidential details. ROT13是一个不错的选择,但是很遗憾,由于一些机密信息,我无法使用它。 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. 安全根本不是问题,只是以某种方式扭曲字符串并在以后检索它。

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. 如果您想隐藏网络上的信息,那么使用SSL绝对是正确的方法。

Javascript and C# both support a number of different "real" encryption algorithms. Javascript和C#都支持许多不同的“真实”加密算法。

check out Javascript DES and 3DES 查看Javascript DES和3DES
Question: Triple DES decryption in classic ASP? 问题: 经典ASP中的三重DES解密?
example: http://jsbin.com/oguye3 示例: http//jsbin.com/oguye3
source: http://cheeso.members.winisp.net/srcview.aspx?dir=DES 来源: http : //cheeso.members.winisp.net/srcview.aspx?dir=DES

DES has known weaknesses, but that library also supports 3DES, which is stronger. DES有已知的弱点,但该库也支持3DES,后者更强大。

Also check out Javascript and AES 还要检查Javascript和AES
Getting SlowAES and RijndaelManaged class in .NET to play together 在.NET中获取SlowAES和RijndaelManaged类一起玩

Here's a working demo of AES in the browser: 这是浏览器中AES的工作演示:
http://jsbin.com/itiye5/3 http://jsbin.com/itiye5/3

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. 如果您正在寻找RSA(常规加密),则可以在客户端使用jsbn http://www-cs-students.stanford.edu/~tjw/jsbn/ javascript库,在服务器端使用标准.Net RSACryptoServiceProvider。

They do cooperate perfectly between each other. 他们之间确实做到了完美的合作。

I hope this helps! 我希望这有帮助!

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中对文本进行编码,这也使得人类难以阅读。 BASE64 naturally offers no security at all, but you can use standard libraries for encoding and decoding. BASE64自然不提供任何安全性,但是您可以使用标准库进行编码和解码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM