/// <summary>
/// DES加密
/// </summary>
/// <param name="encryptString">要加密的字符串字符串</param>
/// <param name="key">密钥</param>
/// <returns></returns>
public static string EncEncrypt(string encryptString, string key)
{
byte[] keyBytes = Encoding.UTF8.GetBytes(key.Substring(0, 8));
byte[] keyIV = keyBytes;
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, provider.CreateEncryptor(keyBytes, keyIV), CryptoStreamMode.Write);
cStream.Write(inputByteArray, 0, inputByteArray.Length);
cStream.FlushFinalBlock();
return Convert.ToBase64String(mStream.ToArray());
}
Des中包含中文文字加密
最新推荐文章于 2022-06-06 15:32:04 发布