嗨我遇到问题或使用Decrypt SelectInfo
错误base-64 char数组的无效长度
我的代码在哪里有问题?
public static string InsertAndUpdate(string strValue,string Value) {
byte[] byKey;
byte[] IV = { 18, 52, 86, 120, 144, 171, 205, 239 };
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(Value.Substring(0, 8));
System.Security.Cryptography.DESCryptoServiceProvider des = new System.Security.Cryptography.DESCryptoServiceProvider();
byte[] inputByteArray = System.Text.Encoding.UTF8.GetBytes(strValue);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateEncryptor(byKey, IV), System.Security.Cryptography.CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch (Exception E)
{
throw E;
}
}
public static string SelectInfo(string strValue, string Value)
{
byte[] byKey;
byte[] IV = { 18, 52, 86, 120, 144, 171, 205, 239 };
byte[] inputByteArray;
//inputByteArray.Length = strText.Length;
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(Value.Substring(0, 8));
System.Security.Cryptography.DESCryptoServiceProvider des = new System.Security.Cryptography.DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(strValue);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateDecryptor(byKey, IV), System.Security.Cryptography.CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
return encoding.GetString(ms.ToArray());
}
catch (Exception E)
{
throw E;
}