想要在Asp.net查询字符串主题中获得帮助 [英] Wants Help in Asp.net Query String topic
本文介绍了想要在Asp.net查询字符串主题中获得帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经编写了这段代码并正常工作。我不知道如何对值进行编码和解码..
可以为任何人提供关于隐藏URL中值的解决方案..
i have written this code and working properly.bt i dont knw how to encode and decode values..
can any one give me solution about hiding the values in the URL..
protected void btnadd_Click(object sender, EventArgs e)
{
string username = txtusername.Text;
string mname = txtmname.Text;
string lname = txtlname.Text;
Response.Redirect("QueryString2.aspx?name="+username+"&name2="+mname+"&name3="+lname);
}
推荐答案
检查此HTTP模块是否允许您在此处加密整个查询字符串 http://madskristensen.net/post/HttpModule-for-query-string-encryption.aspx 一> [ ^ ]
问候
Pawan
Check this HTTP module out that lets you encrypt the entire query string here at http://madskristensen.net/post/HttpModule-for-query-string-encryption.aspx[^]
Regards
Pawan
请点击以下链接
使用C#加密和解密数据 [ ^ ]
谢谢
Please follow the link below
Encrypt and Decrypt Data with C#[^]
Thanks
private static string EncryptionKey = "!#853g`de";
private static byte[] key = { };
private static byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
//Encryption Technique:
public string Encrypt(string Input)
{
try
{
key = System.Text.Encoding.UTF8.GetBytes(EncryptionKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
Byte[] inputByteArray = Encoding.UTF8.GetBytes(Input);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch (Exception ex)
{
return "";
}
}
//Decryption Technique :
public string Decrypt(string Input)
{
Byte[] inputByteArray = new Byte[Input.Length];
try
{
key = System.Text.Encoding.UTF8.GetBytes(EncryptionKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(Input);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
Encoding encoding = Encoding.UTF8;
return encoding.GetString(ms.ToArray());
}
catch (Exception ex)
{
return "";
}
}
这篇关于想要在Asp.net查询字符串主题中获得帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文