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 "";
}
}
...全文
143 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
芹菜大哥 2006-05-29
  • 打赏
  • 举报
回复
谢谢梁亿提供和大家的支持,现在结贴
jinsinuo88 2006-05-29
  • 打赏
  • 举报
回复
加密方法
///input 为 加密内容
///encryptionKeyBytes 为 加密KEy

public string Encrypt()
{
string strResult = "";
string input = "zhaoyingqi";
input = String.Format("{0,5:00000}"+input, input.Length);
byte[] encryptionKeyBytes = new byte[] { 0x39, 0x48, 0x42, 50, 0x38, 0x31, 70, 0x36 };
byte[] rbData = Encoding.Default.GetBytes(input);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
ICryptoTransform desEncrypt = des.CreateEncryptor(encryptionKeyBytes,encryptionKeyBytes);
MemoryStream mStream = new MemoryStream(rbData);
CryptoStream cs = new CryptoStream(mStream, desEncrypt, CryptoStreamMode.Read);
MemoryStream mOut = new MemoryStream();
int bytesRead;
byte[] output = new byte[1024];
do
{
bytesRead = cs.Read(output,0,1024);
if (bytesRead != 0)
mOut.Write(output,0,bytesRead);
} while (bytesRead > 0);
if (mOut.Length == 0)
strResult = "";
else
strResult = Convert.ToBase64String(mOut.GetBuffer(), 0, (int)mOut.Length);
return strResult;
}
Yuna_2z 2006-05-26
  • 打赏
  • 举报
回复
MARK
yuesongboy 2006-05-26
  • 打赏
  • 举报
回复
mark
ggygd 2006-05-26
  • 打赏
  • 举报
回复
up
Darren_chen 2006-05-26
  • 打赏
  • 举报
回复
什么阿
看不懂

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧