0

我已经使用下面的代码为密码创建了一个哈希值。我正在存储从下面的方法返回的值。

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);
}

现在我想解码上面创建的哈希值..我需要密码的字符串值..我该怎么做..?

4

1 回答 1

4

SHA-256 是一种单向哈希算法。您无法从哈希中获取原始文本,除非进行蛮力猜测。

于 2015-07-13T02:06:57.613 回答