首页
社区
课程
招聘
[旧帖] 求这段NET算法的逆运算 0.00雪花
发表于: 2011-10-11 18:57 3004

[旧帖] 求这段NET算法的逆运算 0.00雪花

2011-10-11 18:57
3004
   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,很多不懂

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 36
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
这个就比较复杂点了,这个是DES的算法
2011-10-11 19:05
0
雪    币: 160
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
  木有人出现么
2011-10-12 11:39
0
雪    币: 160
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
我已经找到了解决方法了,本帖自己结贴~
2011-10-13 00:43
0
游客
登录 | 注册 方可回帖
返回
//