I have to do the decryption before comparing the password. I have not used this before can anyone tell me how the decryption code should be like. thanks
public string Encript(string password)
{
System.Security.Cryptography.MD5CryptoServiceProvider objCript =
new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(password);
bs = objCript.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
password = s.ToString();
return password;
}
Like the other users have said before, MD5 is a one-way hash algorithm. You cannot decrypt the hash in order to retrieve the original password. The best you can do is to “guess” the password, hash it with MD5 and compare it to the hash. This is a brute force approach and will generally take a lot of time. And if a salt was used when generating the hash, then it will take even more time.
If you really want to find out the original message you can resort to using rainbow tables. This is basically a database which contains a lot of precomputed hashes, which should bring down the total time of your brute force attack. But if a salt was used, you’re pretty much out of luck here.
A good article on bad passwords, hashes, salts, rainbow tables…etc. can be found here:
Bad passwords are not fun and good entropy is always important: demystifying security fallacies
You aren’t actually trying to break into someone’s site, now are you?