加密的方法EncryptString(string Value),想要把通过的状态和身份证号联合起来的字符串加密,参数如何写?
加密函数:想在其他窗体调用此方法,实现学习通过的状态和身份证号联合加密,加密函数的参数如何写,麻烦高手写详细点,多谢!private const string CIV = "kXw/7X2+fgM=";//密钥
private const string CKEY = "FGJQWRRgKCI=";//初始化向量
//private byte[] byt = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };
static public DESCryptoServiceProvider mCSP = new DESCryptoServiceProvider();
/// <summary>
/// des加密
/// </summary>
/// <param name="Value">原始字符串</param>
/// <returns>加密成功返回加密后的字符串,失败返回源串</returns>
static public string EncryptString(string Value)
{
Value += Guid.NewGuid().ToString();
try
{
ICryptoTransform ct;
MemoryStream ms;
CryptoStream cs;
byte[] byt;
ct = mCSP.CreateEncryptor(Convert.FromBase64String(CKEY), Convert.FromBase64String(CIV));
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());
}
catch
{
return Value;
}
} 加密 string byte
补充:.NET技术 , C#