private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
/// <summary>
/// DES加密字符串
/// </summary>
/// <param name="encryptString">待加密的字符串</param>
/// <param name="encryptKey">加密密钥,要求为8位</param>
/// <returns>加密成功返回加密后的字符串,失败返回源串</returns>
public static string EncryptDES(string encryptString, string encryptKey)
{
try
{
byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
byte[] rgbIV = Keys;
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
DESCryptoServiceProvider dCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rg
DES(Data Encryption Standard) 加密解密
最新推荐文章于 2023-07-15 10:14:39 发布
本文深入探讨了DES(Data Encryption Standard)加密算法的工作原理,包括其64位块大小、56位密钥长度和迭代过程。通过详细的步骤解析了加密和解密的过程,并讨论了DES的安全性和应用局限,同时提到了3DES作为增强安全性的解决方案。
摘要由CSDN通过智能技术生成