Click here to Skip to main content
15,887,998 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi i done in encryption shown below.
plz help decryption




public void encryptmd5()
{

string source =TextBox5.Text;
using (MD5 md5Hash = MD5.Create())
{
string hash = GetMd5Hash(md5Hash, source);
TextBox4.Text = hash;

}
}

static string GetMd5Hash(MD5 md5Hash, string input)
{
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 8; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return sBuilder.ToString();
}
static bool VerifyMd5Hash(MD5 md5Hash, string input, string hash)
{
string hashOfInput = GetMd5Hash(md5Hash, input);
StringComparer comparer = StringComparer.OrdinalIgnoreCase;
if (0 == comparer.Compare(hashOfInput, hash))
{
return true;
}
else
{
return false;
}
}
Posted

1 solution

There is no "decryption" intended for MD5. It is a hashing algorithm, not an encryption method.
And no, there is no need at all to decrypt the stored password: calculate the hash value of the user input and compare that to the stored hash value of the password.
And: also add some salt. And better take a more modern hashing algorithm: there are some tricks to create an input which results in the same hash value.
 
Share this answer
 
Comments
Adarsh chauhan 29-Aug-13 2:33am    
I agree.. +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900