地址栏中的参数如何加密解密啊
怎么对地址栏里面所传递的参数进行加密和解密!在线等 急!我传递的参数也可能是英文和数字,中文可以通过encodeURI 加密,但是英文和数字怎么加密啊 --------------------编程问答-------------------- 可以按一定规则替换一下就行,比如a换成d,b换成e...z换成c然后收到后解密就行 --------------------编程问答-------------------- private const string sKey = "qJzGEh6hESZDVJeCnFPGuxzaiB7NLQM3";
//矢量,矢量可以为空
private const string sIV = "qcDY6X+aPLw=";
/// <summary>
/// 3DES加密
/// </summary>
/// <param name="Value">待加密字符串</param>
/// <param name="sKey">密钥</param>
/// <param name="sIV">矢量</param>
/// <returns>加密后字符串</returns>
private static string encryptString(string Value, string sKey, string sIV)
{
//构造对称算法
SymmetricAlgorithm mCSP = new TripleDESCryptoServiceProvider();
ICryptoTransform ct;
MemoryStream ms;
CryptoStream cs;
byte[] byt;
mCSP.Key = Convert.FromBase64String(sKey);
mCSP.IV = Convert.FromBase64String(sIV);
//指定加密的运算模式
mCSP.Mode = System.Security.Cryptography.CipherMode.ECB;
//获取或设置加密算法的填充模式
mCSP.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
ct = mCSP.CreateEncryptor(mCSP.Key, mCSP.IV);
byt = Encoding.UTF8.GetBytes(Value);
ms = new MemoryStream();
cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
cs.Write(byt, 0, byt.Length);
cs.FlushFinalBlock();
cs.Close();
return Convert.ToBase64String(ms.ToArray());
}
/// <summary>
/// 3DES解密
/// </summary>
/// <param name="Value">待解密字符串</param>
/// <param name="sKey">密钥</param>
/// <param name="sIV">矢量</param>
/// <returns>解密后字符串</returns>
private static string decryptString(string Value, string sKey, string sIV)
{
//构造对称算法
SymmetricAlgorithm mCSP = new TripleDESCryptoServiceProvider();
ICryptoTransform ct;
MemoryStream ms;
CryptoStream cs;
byte[] byt;
mCSP.Key = Convert.FromBase64String(sKey);
mCSP.IV = Convert.FromBase64String(sIV);
mCSP.Mode = System.Security.Cryptography.CipherMode.ECB;
mCSP.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
ct = mCSP.CreateDecryptor(mCSP.Key, mCSP.IV);
byt = Convert.FromBase64String(Value);
ms = new MemoryStream();
cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
cs.Write(byt, 0, byt.Length);
cs.FlushFinalBlock();
cs.Close();
return Encoding.UTF8.GetString(ms.ToArray());
}
public static string encryptStr(string Value)
{
--------------------编程问答-------------------- 我想通过js传递,然后再服务器端接受,我用的是asp。net,有没有简单的方法,函数 --------------------编程问答-------------------- URL重写 ... --------------------编程问答-------------------- 使用RSA加密算法,客户端可以使用公钥进行加密,而服务器端则通过公钥和密钥进行解密。在.net中有现成的类共使用。
using System.Security.Cryptography;
自己去看一下帮助吧。 --------------------编程问答-------------------- Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(strUserName)); --------------------编程问答-------------------- 用DES加密解密算法可以
补充:.NET技术 , ASP.NET