加密查询字符串,包括密钥
我有一个应用程序使用查询字符串在页面之间传递一些值。我发现了一些关于如何加密查询字符串中的值的示例,但问题是我的 KEYS 告诉了更多有关查询字符串的信息,然后是所有整数转换为字符串的值。
有没有办法加密 ASP.NET 中的整个查询字符串(包括键和键值)?
比如:
Default.aspx?value1=40&value2=30&value3=20
谢谢
Default.aspx?56sdf78fgh90sdf4564k34klog5646l
!
I have an app that is using query string to pass some values around pages. I found few examples on how to encrypt values in query string, but the problem is that my KEYS tell more about query string then the values which are all integers converted to string.
Is there a way to encrypt the whole query string in ASP.NET including keys and key values?
Something like:
Default.aspx?value1=40&value2=30&value3=20
to
Default.aspx?56sdf78fgh90sdf4564k34klog5646l
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
上面的许多参考文献都忽略了一个问题,那就是在返回加密字符串之前,URL 编码(在返回字符串之前请参阅下文)。我使用的是 IIS 7.5,它会自动为您“解码”字符串,因此解密“应该”没问题。加密和解密代码如下所示。
There is one issue that many of the references above overlook, and that is just prior to returning the encrypted string, URL Encode (see below right before the string is returned). I am using IIS 7.5, and it will automatically "Decode" the string for you, so the decryption "should" be OK. Both the Encrypt and Decrypt code is shown below.
网上有很多例子。
其中一些:
如何在 asp.net 中加密查询字符串?
如何在asp.net中传递加密的查询字符串。网
http://www.codeproject.com/Articles/33350/Encrypting-Query-Strings
http://www.keyvan.ms/how-to-encrypt-query-string-parameters-in-asp-net
http://forums.asp.net/t/989552.aspx/1
现在你说你也喜欢加密密钥,实际上你是什么所要做的就是加密它们所有的 url 行,然后你只需读取 RawUrl 之后的内容?并解密它。
There are many examples on web.
some of them:
How can I encrypt a querystring in asp.net?
how to pass encrypted query string in asp.net
http://www.codeproject.com/Articles/33350/Encrypting-Query-Strings
http://www.keyvan.ms/how-to-encrypt-query-string-parameters-in-asp-net
http://forums.asp.net/t/989552.aspx/1
Now you say that you do like to encrypt the keys also, actually what you have to do is to encrypt them all url line, and then you just read the RawUrl what after the ? and decrypt it.