Password Hash

This takes a text input and creates a one-way hash using bcrypt, argon2i or argon2id. This can then be inserted into a database or similar.

How to create a password hash

  1. Type the password in Input.
  2. Choose an Algorithm. PASSWORD_DEFAULT is the safe choice if you're unsure.
  3. Set the Cost from 4 to 12 (10 is PHP's default).
  4. Press Send. Copy the hash with Copy output, or press Verify password to test it straight away in Password verify.

Reading the result

A bcrypt hash looks like $2y$10$pY0ty1.0WE2eRKbqxXmtbuMdfOQcEhU/mSkGgW0vjNt9QA5fkox9i. 2y is the algorithm, 10 the cost, the next 22 characters the random salt and the rest the hash itself. An Argon2id hash starts with $argon2id$v=19$m=65536,t=4,p=1$: version, memory in KiB, iterations and threads.

Because a new random salt is used each time, the same password gives a different hash on every submit. That is expected, and every one of them verifies.

About the cost

The cost setting applies to bcrypt (PASSWORD_DEFAULT and PASSWORD_BCRYPT). Each step up doubles the work needed to compute, and to crack, the hash. Pick the highest value your login server can handle in roughly a tenth of a second. Argon2 doesn't use this setting; it uses PHP's defaults, which you can read from the hash.

Using the hash in your own code

In PHP, store the hash in a column that can hold at least 255 characters, then check a login with password_verify($password, $hash). Most other languages have bcrypt and Argon2 libraries that read the same format.

Limits

  • The cost is limited to 12 here to keep the shared server responsive.
  • There is a limit of about 10 hashes per minute from one address.
  • bcrypt only uses the first 72 bytes of a password.

FAQ

Should I hash real production passwords here? It's better not to type a live password into any website. Use this to learn the format, create test fixtures or seed a development account.

Can a hash be turned back into the password? No. Hashing is one-way; it can only be checked against a guess.

password_hash()

creates password hashes using one-way algorithms.

From php.net:

  1. PASSWORD_DEFAULT Use the bcrypt algorithm (default as of PHP 5.5.0). Note that this constant is designed to change over time as new and stronger algorithms are added to PHP. For that reason, the length of the result from using this identifier can change over time. Therefore, it is recommended to store the result in a database column that can expand beyond 60 characters (255 characters would be a good choice).
  2. PASSWORD_BCRYPT - Use the CRYPT_BLOWFISH algorithm to create the hash. This will produce a standard crypt() compatible hash using the "$2y$" identifier. The result will always be a 60 character string, or false on failure.
  3. PASSWORD_ARGON2I - Use the Argon2i hashing algorithm to create the hash. This algorithm is only available if PHP has been compiled with Argon2 support.
  4. PASSWORD_ARGON2ID - Use the Argon2id hashing algorithm to create the hash. This algorithm is only available if PHP has been compiled with Argon2 support.
Cost:
- denotes the algorithmic cost that should be used.