Salting: Is it reasonable to use the user name?

前端 未结 6 2043
礼貌的吻别
礼貌的吻别 2021-02-20 16:53

I am debating using user-names as a means to salt passwords, instead of storing a random string along with the names. My justification is that the purpose of the salt is to prev

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 17:39

    This method was deemed secure enough for the working group that created HTTP digest authentication which operates with a hash of the string "username:realm:password".

    I think you would be fine seeing as this decision is secret. If someone steals your database and source code to see how you actually implemented your hashing, well what are they logging in to access at that point? The website that displays the data in the database that they've already stolen?

    In this case a salt buys your user a couple of security benefits. First, if the thief has precomputed values (rainbow tables) they would have to recompute them for every single user in order to do their attack; if the thief is after a single user's password this isn't a big win.

    Second, the hashes for all users will always be different even if they share the same password, so the thief wouldn't get any hash collisions for free (crack one user get 300 passwords).

    These two benefits help protect your users that may use the same password at multiple sites even if the thief happens to acquire the databases of other sites.

    So while a salt for password hashing is best kept secret (which in your case the exact data used for the salt would be) it does still provide benefits even if it is compromised.

提交回复
热议问题