Using SHA256 + SHA512 hash for password?

匿名 (未验证) 提交于 2019-12-03 01:23:02

问题:

I'm creating a method that I will use to hash password to store in a database. I would like to seek advice if my methods in hashing is sufficient or overkill for the task.

    Dim result As Byte()     Dim mixer As String      Try         Dim sha As New SHA512CryptoServiceProvider          mixer = txt_salt.Text.ToUpper + txt_pass.Text.Trim         result = sha.ComputeHash(System.Text.Encoding.ASCII.GetBytes(mixer))          txt_sha.Text = Convert.ToBase64String(result)     Catch ex As Exception         MsgBox(ex.ToString)     End Try 

Thanks.

回答1:

It is insufficient.

  1. No salt:
    • vulnerable to rainbow tables (if hashes are leaked)
    • solution: use random salt in large domain
  2. Hashes are too fast:
    • vulnerable to brute-force (if hashes are leaked)
    • most hashing algorithms are designed to be fast
    • solution: bcrypt, scrypt or multiple (many!!!) rounds
  3. No HMAC:
    • does not have additional "server secret" (stored outside db!)
    • solution: hmac-sha1, etc.
  4. Not part of a well-tested library/framework for authentication:
    • this is a "roll your own" implementation
    • solution: don't reinvent a wheel, unless it's one of these or these :)

As far as "bits" go, SHA1 is perfectly fine with 160 (but it is not fine [by itself] for other reasons). Doing both SHA256+SH512 just complicates the matter for zero gain. (Actually, it is a very slight net loss due to the extra storage requirements.)

I suggest using an existing library/system, unless this is an academic project :)

Happy coding.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!