使用 SHA1 的密码解密问题

Password Decryption Issue using SHA1

我正在使用以下代码加密我的密码。

        public static string GetSHA1HashData(string password)
        {
            //create new instance of md5
            SHA1 sha1 = SHA1.Create();

            //convert the input text to array of bytes
            byte[] hashData = sha1.ComputeHash(Encoding.Default.GetBytes(password));

            //create new instance of StringBuilder to save hashed data
            StringBuilder returnValue = new StringBuilder();

            //loop for each byte and add it to StringBuilder
            for (int i = 0; i < hashData.Length; i++)
            {
                returnValue.Append(hashData[i].ToString());
            }
            // return hexadecimal string
            return returnValue.ToString();
        }

但我也想创建解密代码。我已经尝试过,但找不到好的解决方案。那么你能帮我解决这个问题吗?

这里我使用了System.Security.Cryptography => SHA1 : HashAlgorithm

提前致谢。

哈希值无法解密:

  1. 哈希是 (例如,仅 256 位),而 String 是任意的 (最多 2GB ), 所以有很多 String 具有相同的散列 (歧义)
  2. 散列算法 (SHA1) 经过专门设计,因此找出具有给定散列值(复杂性[=29]的字符串是一项困难任务=])

而不是解密比较散列值:如果用户提供的密码相同 hash value表示一个存储的hash,那么密码就是正确一个。