Pcornel
Security · Hashing

bcrypt

Cheat sheet · https://pcornel.dk/topic.php?topic=4715

Back to the Topic

Answer

bcrypt is a well-established password hashing algorithm with a salt and adjustable cost factor, such as cost 12. It truncates passwords at 72 bytes, which matters for very long passphrases.

Remember

  • The cost factor sets work per hash.
  • Passwords are truncated at 72 bytes.
  • The salt is included in the hash string.

First checks

  • python3 -c "import bcrypt;print(bcrypt.hashpw(b'pw',bcrypt.gensalt(12)))" — bcrypt cost 12
  • Cost factor — ≥ 10–12
  • 72-byte input limit — pre-hash handling

Verify in this order

password + salt + cost → bcrypt hash

Where it usually breaks

First mismatch in key/secret generation → storage/rotation → trust/certificate validation → protocol negotiation → cryptographic operation → peer/application verification; preserve identity/policy/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=4715

Confirmation

Confirm action

Continue?