简体   繁体   中英

get string value of password from hash value

I have created a hash value for password using the below code.. I am storing the value which is returned from the below method.

public static string CreateHash(string password)
{
    // Generate a random salt
    RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider();
    byte[] salt = new byte[24];
    csprng.GetBytes(salt);
    HashAlgorithm hashAlg = new SHA256CryptoServiceProvider();
    byte[] bytValue = System.Text.Encoding.UTF8.GetBytes(salt + ":" + password);
    // Hash the password and encode the parameters
    byte[] bytHash = hashAlg.ComputeHash(bytValue);
    return
        Convert.ToBase64String(bytHash);
}

Now i want to decode the value of the above created hash.. I need the string value of the password.. How do i do that..?

SHA-256 is a one-way hash algorithm. You can't get the original text back from the hash, short of brute-force guessing.

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