简体   繁体   中英

decrypt md5 hash confusion

I have develop a simple MD5 hash like this:

public static string Hash(string value)
{
    byte[] valueBytes = new byte[value.Length * 2];

    Encoder encoder = Encoding.Unicode.GetEncoder();
    encoder.GetBytes(value.ToCharArray(), 0, value.Length, valueBytes, 0, true);

    MD5 md5 = new MD5CryptoServiceProvider();
    byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes("123456"));

    StringBuilder stringBuilder = new StringBuilder();

    for (int i = 0; i < hashBytes.Length; i++)
    {
        stringBuilder.Append(hashBytes[i].ToString("x2"));
    }

    return stringBuilder.ToString();
}

But now, I want to decrypt the result of this code to original text. But I don't know which function I should use?

My hash function is:

byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes("123456"));

您不(无法)解密哈希,而是针对给定的值再次执行加密,以验证该值与哈希假装属于的值相同。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM