我是网络开发的新手。我正在制作一个网站的课程项目,我正在网址中传输数据。我想为用户隐藏那些数据,以便将来不能更改它。 我在ASP.net上工作。非常感谢帮助。
答案 0 :(得分:1)
您无法隐藏在网址中传输的数据。发送未在url中显示的数据的最简单方法是使用POST请求而不是GET请求。
答案 1 :(得分:1)
您无法隐藏在网址中传输的数据 但你可以加密网址中的数据 像我的网址是text.aspx?Firstname = Robin& LastName = Hood 那么应该显示像test.aspx?Firstname = 121sdnasdkjn121928& LastName = sadklsdn12981029 类似的东西 然后你需要解密数据的地方,它将返回实际数据
这是加密或解密的功能
public static string Encrypt(string clearText)
{
try
{
string EncryptionKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890";
byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);
using (Aes encryptor = Aes.Create())
{
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
encryptor.Key = pdb.GetBytes(32);
encryptor.IV = pdb.GetBytes(16);
using (MemoryStream ms = new MemoryStream())
{
using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
{
cs.Write(clearBytes, 0, clearBytes.Length);
cs.Close();
}
clearText = Convert.ToBase64String(ms.ToArray());
}
}
return clearText;
}
catch
{
return null;
}
}
public static string Decrypt(string cipherText)
{
try
{
string EncryptionKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890";
byte[] cipherBytes = Convert.FromBase64String(cipherText.Replace(" ", "+"));
using (Aes encryptor = Aes.Create())
{
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
encryptor.Key = pdb.GetBytes(32);
encryptor.IV = pdb.GetBytes(16);
using (MemoryStream ms = new MemoryStream())
{
using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
{
cs.Write(cipherBytes, 0, cipherBytes.Length);
cs.Close();
}
cipherText = Encoding.Unicode.GetString(ms.ToArray());
}
}
return cipherText;
}
catch
{
return null;
}
}
OR
您也可以使用术语网址路由来隐藏真实网址并向用户显示虚假网址 喜欢而不是localhost:1544 / test.aspx它将显示localhost:1544 / test或localhost:1544 / what_ever_you_want 它也会隐藏.aspx扩展名
希望这会有所帮助