2

I am currently looking for a librarly to store a salted, hashed password in a web app. I came across mindrot's jbcrypt and think it might be the right choice (also see https://security.stackexchange.com/questions/21184/safe-to-use-jbcrypt-and-recommend-it-to-my-organization). However, one thing is puzzling me a little bit about the code. Generally, hashing and salting a password is done by calling

String hashed = BCrypt.hashpw(password, BCrypt.gensalt(12));

which uses a generated salt. To check a password later on, here you can see (as well as on the mindrot page) that the

if (BCrypt.checkpw(candidate, hashed))

function is invoked with a plain text candidate. Also, in the coding of jbcrypt is says

public static boolean checkpw(String plaintext, String hashed)

Now my question is how can you compare a plain text password to a salted+hashed String without having the salt at comparison time (as it is not passed into the checkpw-function, obviously)?

Community
  • 1
  • 1
Christian
  • 303
  • 2
  • 15

0 Answers0