How can I hash a password in Java?

前端 未结 13 2347
暖寄归人
暖寄归人 2020-11-22 05:00

I need to hash passwords for storage in a database. How can I do this in Java?

I was hoping to take the plain text password, add a random salt, then store the salt a

13条回答
  •  爱一瞬间的悲伤
    2020-11-22 05:37

    You can comput hashes using MessageDigest, but this is wrong in terms of security. Hashes are not to be used for storing passwords, as they are easily breakable.

    You should use another algorithm like bcrypt, PBKDF2 and scrypt to store you passwords. See here.

提交回复
热议问题