200分相送,那位大侠可以帮我写出这个函数的逆过程
芹菜大哥 2006-05-26 08:59:54 要求下面这个过程的相反函数,即输入一个结果(如:celerySingleLicense)就能得到下面这个函数的输入
using System;
using System.Security.Cryptography;
using System.IO;
using System.Text;
private string DecryptLicenseData(string input)
{
byte[] encryptionKeyBytes = new byte[] { 0x39, 0x48, 0x42, 50, 0x38, 0x31, 70, 0x36 }
DESCryptoServiceProvider provider1 = new DESCryptoServiceProvider();
ICryptoTransform transform1 = provider1.CreateDecryptor(encryptionKeyBytes, encryptionKeyBytes); //创建解密对象
MemoryStream stream1 = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream1, transform1, CryptoStreamMode.Write); //将数据流链接到加密转换流
byte[] buffer1 = new byte[input.Length]; //输入字符转换为byte数组
try
{
buffer1 = Convert.FromBase64CharArray(input.ToCharArray(), 0, input.Length);
}
catch (Exception)
{
return "Error. Input Data is not base64 encoded.";
}
long num1 = 0;
long num2 = input.Length;
try
{
while (num2 >= num1)
{
stream2.Write(buffer1, 0, buffer1.Length);
num1 = stream1.Length + Convert.ToUInt32((int) ((buffer1.Length / provider1.BlockSize) * provider1.BlockSize));
}
string text1 = new ASCIIEncoding().GetString(stream1.GetBuffer(), 0, (int) stream1.Length);
string text2 = text1.Substring(0, 5);
int num3 = Convert.ToInt32(text2);
return text1.Substring(5, num3);
}
catch (Exception)
{
return "";
}
}