[Django]-How can I set salt for bcrypt.hashpw?

2👍

I think that, as in the example found in the project page, you need something like this:

salt = bcrypt.gensalt()
password = bcrypt.hashpw(password, salt)
repeatpassword = bcrypt.hashpw(repeatpassword,salt)

4👍

The format for salt is:

$Version$log2(NumRounds)$salt

where:

  • Version is 2,
  • 0 <= log2(NumRounds) < 32,
  • salt is a 22-byte base-64 encoded string.

I suggest you use bcrypt.gensalt() instead. There’s no good reason for you to provide your own salt.

Leave a comment