-2

How to convert Md5Hash values to string..

i have convert string values to hash..

i have used the to method to convert MD5Hash to string

`
public static string ConvertStringtoMD5(string strword)
        {
            MD5 md5 = MD5.Create();

        byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(strword);

        byte[] hash = md5.ComputeHash(inputBytes);

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < hash.Length; i++)
        {
            sb.Append(hash[i].ToString("x2"));
        }
        return sb.ToString();
    }

`

string has=ConvertStringtoMD5("prasad");

its returns hash value = 'c246ad314ab52745b71bb00f4608c82a'

using this hash values i need to get the string called prasad

how can i achive this, can you suggest to achive this..

Prasad Raja
  • 685
  • 1
  • 9
  • 37
  • 2
    The whole point of a hash function is that they are a one way hash function. Once you run a string through a hash function it is theoretically impossible to get back to the original string. – Zippit Oct 29 '13 at 04:54
  • possible duplicate of [Reversing a md5 hash algorithm in C#](http://stackoverflow.com/questions/5917658/reversing-a-md5-hash-algorithm-in-c-sharp) – griegs Oct 29 '13 at 04:55
  • 2
    possible duplicate of [Is it possible to decrypt md5 hashes?](http://stackoverflow.com/questions/1240852/is-it-possible-to-decrypt-md5-hashes) – Alastair Pitts Oct 29 '13 at 04:55
  • Seems everyone is saying it's impossible but if you plug your hash into this site, http://reverse-hash-lookup.online-domain-tools.com/ you get back prasad, which is a bit of a worry because it SHOULD be one way! – griegs Oct 29 '13 at 04:57
  • You should not be using System.Text.Encoding.ASCII, please use Utf8 so that the code is international. – Richard Schneider Oct 29 '13 at 05:31
  • @greigs, if you are worried about security, then never ever use MD5. At a minimum use SHA-1. Most people are now paranoid and are using SHA-256. – Richard Schneider Oct 29 '13 at 05:34

5 Answers5

8

Hashes are one-way. They are not designed to be unencoded once they are encoded. That being said, they can be cracked using Rainbow Tables. To create your own rainbow table in C#, you can look at this article.

Keep in mind that Rainbow Tables do have limitations and do not work 100% of the time. This is especially true if the MD5 hash has been salted.

Icemanind
  • 47,519
  • 50
  • 171
  • 296
1

Hashing functions are only one way functions - there is no way to get the input.

You could try using e.g. rainbow tables, but because number of possible hashes is limited, there is a chance that you will get another string with the same MD5 hash instead of the input.

MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263
1

Hashing is one way function. This means that you can't get the original input by using the hashed output.

One of the ways to compare if two inputs are the same is to hash the new input and check it against the already hashed output you already have, then simply check if the values are the same. Keep in mind, that in some algorithms, collisions can occur, which means two different inputs might generate the same output.

coolmine
  • 4,427
  • 2
  • 33
  • 45
0

MD5 is a one-way hash, you cannot (without brute force techniques) obtain the original string from the hash.

Alastair Pitts
  • 19,423
  • 9
  • 68
  • 97
0

You can't reverse MD5 method, it's a hashing algorithm. There are infinite values that can result in the same hash string.

regulus
  • 1,572
  • 12
  • 18