我用下面的代碼如何SHA512哈希值進行解密,以實際字符串在C#
HashAlgorithm hashAlgorithm = null;
hashAlgorithm = new SHA512CryptoServiceProvider();
try
{
byte[] byteValue = Encoding.UTF8.GetBytes(source);
byte[] hashValue = hashAlgorithm.ComputeHash(byteValue);
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= hashValue.Length - 1; i++)
{
sb.AppendFormat("{0:x2}", hashValue[i]);
}
return Convert.ToString(sb);
}
catch
{
throw;
}
後,我在數據庫中保存它
加密密碼。 現在我想通過解密來檢索實際的密碼。請幫我
你誤會了哈希的作用。請閱讀http://en.wikipedia.org/wiki/Cryptographic_hash_function – 2014-12-02 09:57:24
一個聰明的傢伙說:「如何從牛漢堡中取出活牛?」。 – C4u 2014-12-02 10:06:41
另一個問題是,像SHA-2這樣的常規加密哈希不是您想要爲密碼哈希做的。你想要一個緩慢的鹽漬散列。有關詳細信息,請參閱security.se上的[如何安全地哈希密碼?](http://security.stackexchange.com/questions/211/how-to-securely-hash-passwords)。 – CodesInChaos 2014-12-02 16:54:44