dec = 需要逆推的字符串;
string reg = Crypt.DecryptString(Crypt.DesBase64Decrypt(Crypt.DesBase64DecryptForID5(dec)));
string[] tem = reg.Split(new char[] { ',' });
string temstr = tem[tem.Length - 1];
reg = reg.Replace("," + temstr, "");
int day = Convert.ToInt32(temstr);
if (!(reg == 已知的需要比较的字符串)
{
isReg = false;
return false;
}
public static string DecryptString(string input)
{
if (input.Equals(string.Empty))
{
return input;
}
byte[] byKey = new byte[] { 0x63, 0x68, 0x65, 110, 0x79, 0x75, 0x61, 110 };
byte[] IV = new byte[] { 0xfe, 220, 0xba, 0x98, 0x76, 0x54, 50, 0x10 };
byte[] inputByteArray = new byte[input.Length];
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(input);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
Encoding encoding = new UTF8Encoding();
return encoding.GetString(ms.ToArray());
}
public static string DesBase64Decrypt(string input)
{
DES des = DES.Create();
des.Mode = CipherMode.ECB;
byte[] Key = new byte[] { 0x38, 50, 0x37, 0x38, 0x38, 0x37, 0x31, 0x31 };
byte[] IV = new byte[8];
ICryptoTransform ct = des.CreateDecryptor(Key, IV);
byte[] byt = Convert.FromBase64String(input);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
cs.Write(byt, 0, byt.Length);
cs.FlushFinalBlock();
cs.Close();
return Encoding.GetEncoding("GB2312").GetString(ms.ToArray());
}
public static DES Create()
{
return Create("System.Security.Cryptography.DES");
}
[Serializable, ComVisible(true)]
public enum CipherMode
{
CBC = 1,
CFB = 4,
CTS = 5,
ECB = 2,
OFB = 3
}
public static string DesBase64DecryptForID5(string input)
{
DES des = DES.Create();
des.Mode = CipherMode.CBC;
byte[] Key = new byte[] { 0x38, 50, 0x37, 0x38, 0x38, 0x37, 0x31, 0x31 };
byte[] IV = new byte[] { 0x38, 50, 0x37, 0x38, 0x38, 0x37, 0x31, 0x31 };
ICryptoTransform ct = des.CreateDecryptor(Key, IV);
byte[] byt = Convert.FromBase64String(input);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
cs.Write(byt, 0, byt.Length);
cs.FlushFinalBlock();
cs.Close();
return Encoding.GetEncoding("GB2312").GetString(ms.ToArray());
}
如何才能通过已知的需要比较的字符串算出需要逆推的字符串dec呢?一个朋友给我的考验题,最新接触NET,很多不懂。之前在另一个板发过了,发现发错了,重新发下,版主见谅
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)