简体   繁体   English

使用SHA256 + SHA512哈希密码?

[英]Using SHA256 + SHA512 hash for password?

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. 谢谢。

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 解决方案: bcryptscrypt或multiple(很多!!!)回合
  3. No HMAC: 没有HMAC:
    • does not have additional "server secret" (stored outside db!) 没有额外的“服务器秘密”(存储在db之外!)
    • solution: hmac-sha1 , etc. 解决方案: hmac-sha1
  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). 就“位”而言,SHA1完全没有160(但由于其他原因,它本身并不好)。 Doing both SHA256+SH512 just complicates the matter for zero gain . 同时执行SHA256 + SH512只会使零增益复杂化。 (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. 快乐的编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM