加密/解密查询字符串值,而无需写入任何单独的类文件. [英] Encrypting/Decrypting a querystring value with out write any seperate class file.

查看:63
本文介绍了加密/解密查询字符串值,而无需写入任何单独的类文件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

如何在不编写单独的类文件的情况下加密/解密查询字符串值.我使用了Server.HtmlEncode/Server.HtmlDecode和Server.UrlEncode/Server.UrlDecode.如下所示,但不起作用.

传递查询字符串值时:

Dear All,

How to encrypt / decrypt a query string value with out writing a seperate class file. I used Server.HtmlEncode/Server.HtmlDecode and Server.UrlEncode/Server.UrlDecode. Like below but not working.

When passing query string value :

string userId = "44";
Response.Redirect("~/Result.aspx?userId="+ Server.HtmlEncode(userId));


接收查询字符串值时:


When receiving query string value:

if(Requeset.QueryString["userId"]!=null)
{
    string UserId = Sever.HtmlDecode(Request.QueryString["userId"].ToString());
    // ------ here getting the data from database basing on this userId value.
}


我使用了HtmlEncode/Decode和UrlEncode/Decode,但是没有用.解决方案的网址链接中未加密userId.请任何人对此问题有任何想法.让我知道.

在此先感谢...


I used HtmlEncode/Decode and UrlEncode/Decode but no use. userId is not encrypted in url link of solution. please anybody have any idea this issue. let me know.

Thanks in Advance...

推荐答案

Dim encrypter As New MD5CryptoServiceProvider()
Dim b As Byte()
Dim encoder As New UTF8Encoding()
b = encrypter.ComputeHash(encoder.GetBytes(querysting))



我只知道您可以通过这种方式对字符串进行加密.....



I only know in this way u can encrypt the string.....


这篇关于加密/解密查询字符串值,而无需写入任何单独的类文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆