-
-
未解决
[求助]DES加密算法求解
-
发表于:
2019-10-23 16:31
2305
-
public static string Encrypt(string a_strString, string a_strKey)
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.Default.GetBytes(a_strString);
des.Key = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(a_strKey, "md5").Substring(0, 8));
des.IV = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(a_strKey, "md5").Substring(0, 8));
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
StringBuilder ret = new StringBuilder();
foreach (byte b in ms.ToArray())
{
ret.AppendFormat("{0:X2}", b);
}
return ret.ToString();
请问上面代码中Key和IV值都是md5加密取前8位对吗?可是我加密后的密文和代码加密后的不一样,求解?
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!