Click here to Skip to main content
15,902,896 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using this code to make a encrypted password.I want to decode the generated string to its original.
C#
public string CreateHash(string password, string salt)
   {
       // Get a byte array containing the combined password + salt.
       string authDetails = password + salt;
       byte[] authBytes = System.Text.Encoding.ASCII.GetBytes(authDetails);
       // Use MD5 to compute the hash of the byte array, and return the hash as
       // a Base64-encoded string.
       var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
       byte[] hashedBytes = md5.ComputeHash(authBytes);
       string hash = Convert.ToBase64String(hashedBytes);
       return hash;
   }
Posted
Updated 3-May-18 17:07pm
Comments
[no name] 28-May-13 8:04am    
MD5 is a hash, so you can't get the original back.

MD5 hashes can not be "decrypted", thats the whole point of MD5.
At max, you can try to look them up in a rainbow table.

Here are some sites that support this:
http://tools.benramsey.com/md5/
 
Share this answer
 
Comments
Maciej Los 28-May-13 8:05am    
Good answer! +5!
At the same time as mine ;)
It's not possible MD5 algorithm is known as one-way hashing function. Please, see this: http://en.wikipedia.org/wiki/MD5[^]
 
Share this answer
 
Comments
RelicV 28-May-13 8:08am    
You could decrypt the value though using the below link, though I've not personally used it.

http://www.md5decrypt.org/
Hi,

MD5 is a one way algorithm. it is encrypted but can't be decrypted.

still i have a code to decrypt the string.

public string DecryptPassowrd(object obj)
    {
        string password = obj.ToString();

        System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();

        System.Text.Decoder utf8Decode = encoder.GetDecoder();

        byte[] todecode_byte = Convert.FromBase64String(password.Replace("","+"));

        int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);

        char[] decoded_char = new char[charCount];

        utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);

        string result = new String(decoded_char);

        return result;

    }


Let me know if it works for you or not?

Mark if it works for you.

thanks.
 
Share this answer
 
Comments
Tirthankar Dutta 28-May-13 8:39am    
No this did not work..

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