Dtcms动力启航密码的加密和解密过程

分析了一下.贴上代码.
using System;
using System.Security.Cryptography;
using System.Text;
using System.Security;
using System.IO;

public class DESEncrypt
{
    public static string Md5(string s)
    {
        using (var md5 = MD5.Create())
        {
            var result = md5.ComputeHash(Encoding.UTF8.GetBytes(s));
            var strResult = BitConverter.ToString(result);
            return strResult.Replace("-", "").ToUpper();
        }

    }


    // Token: 0x06000009 RID: 9 RVA: 0x00002118 File Offset: 0x00000318
    public static string Encrypt(string Text, string sKey)
    {
        DESCryptoServiceProvider descryptoServiceProvider = new DESCryptoServiceProvider();
        byte[] bytes = Encoding.Default.GetBytes(Text);
        descryptoServiceProvider.Key = Encoding.ASCII.GetBytes(Md5(sKey).Substring(0,8));
        descryptoServiceProvider.IV = Encoding.ASCII.GetBytes(Md5(sKey).Substring(0,8));
        MemoryStream memoryStream = new MemoryStream();
        CryptoStream cryptoStream = new CryptoStream(memoryStream, descryptoServiceProvider.CreateEncryptor(), CryptoStreamMode.Write);
        cryptoStream.Write(bytes, 0, bytes.Length);
        cryptoStream.FlushFinalBlock();
        StringBuilder stringBuilder = new StringBuilder();
        foreach (byte b in memoryStream.ToArray())
        {
            stringBuilder.AppendFormat("{0:X2}", b);
        }
        return stringBuilder.ToString();
    }



    // Token: 0x0600000B RID: 11 RVA: 0x000021F4 File Offset: 0x000003F4
    public static string Decrypt(string Text, string sKey)
    {
        DESCryptoServiceProvider descryptoServiceProvider = new DESCryptoServiceProvider();
        int num = Text.Length / 2;
        byte[] array = new byte[num];
        for (int i = 0; i < num; i++)
        {
            int num2 = Convert.ToInt32(Text.Substring(i * 2, 2), 16);
            array[i] = (byte)num2;
        }
        descryptoServiceProvider.Key = Encoding.ASCII.GetBytes(Md5(sKey).Substring(0,8));
        descryptoServiceProvider.IV = Encoding.ASCII.GetBytes(Md5(sKey).Substring(0,8));
        MemoryStream memoryStream = new MemoryStream();
        CryptoStream cryptoStream = new CryptoStream(memoryStream, descryptoServiceProvider.CreateDecryptor(), CryptoStreamMode.Write);
        cryptoStream.Write(array, 0, array.Length);
        cryptoStream.FlushFinalBlock();
        return Encoding.Default.GetString(memoryStream.ToArray());
    }


        public static void Main()
{

    Console.WriteLine(Decrypt("pass","salt"));
}

}

把pass 和 salt替换即可解密.

本文链接:

http://www.hentai6.cn/index.php/archives/36/
1 + 7 =
快来做第一个评论的人吧~