Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does salt work in Rails' has_secure_password

From what I understand from salting to make an encrypted password more secure, I would generate a random number (the salt) and store it along side the hashed password, in the user record (for example.) I would concatenate the salt with the plaintext password and then encrypt it (hash). The resulting hash would be much more difficult to crack. This process would be repeated to verify the password.

Looking at has_secure_password and bcrypt_ruby (disclosure: I am not a security expert) I don't see how that is done, as the only thing stored in the user record is the hashed password. Where's the salt?

like image 686
pitosalas Avatar asked Jun 13 '12 00:06

pitosalas


1 Answers

The password hash and salt are saved in a string column called password_digest in the database. See this question.

like image 88
Eric Andres Avatar answered Oct 11 '22 06:10

Eric Andres