C#,一个加密函数,本人C#小白,求解密函数代码
publicstaticstringToDecrypt(stringstrText,stringsDecrKey){byte[]rgbKey=null;byte[]rgb...
public static string ToDecrypt(string strText, string sDecrKey)
{
byte[] rgbKey = null;
byte[] rgbIV = new byte[] { 18, 52, 86, 120, 144, 171, 205, 239 };
byte[] buffer = new byte[strText.Length];
try
{
rgbKey = Encoding.UTF8.GetBytes(sDecrKey.Substring(0, 8));
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
buffer = Convert.FromBase64String(strText);
MemoryStream stream = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
stream2.Write(buffer, 0, buffer.Length);
stream2.FlushFinalBlock();
Encoding encoding = new UTF8Encoding();
return encoding.GetString(stream.ToArray());
}
catch (Exception exception)
{
return exception.Message.ToString();
}
}
没分了,跪谢大家帮忙! 展开
{
byte[] rgbKey = null;
byte[] rgbIV = new byte[] { 18, 52, 86, 120, 144, 171, 205, 239 };
byte[] buffer = new byte[strText.Length];
try
{
rgbKey = Encoding.UTF8.GetBytes(sDecrKey.Substring(0, 8));
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
buffer = Convert.FromBase64String(strText);
MemoryStream stream = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
stream2.Write(buffer, 0, buffer.Length);
stream2.FlushFinalBlock();
Encoding encoding = new UTF8Encoding();
return encoding.GetString(stream.ToArray());
}
catch (Exception exception)
{
return exception.Message.ToString();
}
}
没分了,跪谢大家帮忙! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询