DES加密解密函数
// 默认密钥向量 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();