Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

PHP Password Hash Generator (password_hash & password_verify)

Create password hashes exactly like PHP's password_hash() does, with bcrypt or Argon2id, and get ready-to-paste PHP, SQL and Laravel code. Test any stored hash with password_verify().

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
password_hash()
password_verify()

Runs in your browser. Passwords never leave this page. Hashes work with PHP's password_verify()

How to use the PHP password_hash tool#

  1. Type the password and choose the Algorithm: PASSWORD_DEFAULT (bcrypt) for most apps, or PASSWORD_ARGON2ID if your PHP supports it.
  2. For PASSWORD_DEFAULT, pick your PHP version: PHP 8.4 raised the default bcrypt cost from 10 to 12.
  3. Press Generate hash. Copy the hash, or use the ready SQL or Laravel code under the tool to put it straight into your users table.
  4. To test a stored hash, use password_verify() on the right. It also tells you if password_needs_rehash() would return true with your current settings.

Examples#

Check a bcrypt hash made by PHP

Input
secret123
Output
✓ password_verify() returns true

This $2y$ hash was created by PHP's password_hash(), the same format Laravel and most PHP apps store.

Check an Argon2id hash made by PHP

Input
secret123
Output
✓ password_verify() returns true

PHP's default Argon2id settings: 64 MiB of memory, 4 iterations, 1 thread.

Generate a PASSWORD_DEFAULT hash

Input
correct horse battery staple
Output
$2y$12$… plus ready PHP, SQL and Laravel code

Each hash is different because of the random salt. Copy the SQL line to reset a user's password directly in the database.

How PHP hashes passwords#

PHP has a built-in password API: password_hash() creates a salted, slow hash, and password_verify() checks a password against it. The algorithm, cost and salt are all stored inside the hash string, so you only need one database column and never have to manage salts yourself. This tool produces hashes in exactly the same format, so they work with password_verify() in any PHP application.

The algorithms#

ConstantAlgorithmHash starts withDefault settings
PASSWORD_DEFAULTbcrypt (today)$2y$cost 12 in PHP 8.4+, cost 10 before
PASSWORD_BCRYPTbcrypt$2y$same, cost adjustable
PASSWORD_ARGON2IDArgon2id$argon2id$64 MiB memory, time cost 4, 1 thread
PASSWORD_ARGON2IArgon2i$argon2i$same as Argon2id

PASSWORD_DEFAULT may change to a stronger algorithm in a future PHP version. That is why the PHP manual recommends storing hashes in a column of at least 255 characters. Argon2 is only available if PHP was built with Argon2 support; check with defined('PASSWORD_ARGON2ID').

The three functions you need#

php
// 1. When a user registers or changes their password$hash = password_hash($password, PASSWORD_DEFAULT); // 2. When a user logs inif (password_verify($password, $user->password)) {    // 3. Upgrade old hashes after a successful login    if (password_needs_rehash($user->password, PASSWORD_DEFAULT)) {        $user->password = password_hash($password, PASSWORD_DEFAULT);        $user->save();    }}

password_needs_rehash() returns true when a stored hash uses a different algorithm or weaker settings than the ones you pass. Calling it after every successful login moves all users to stronger hashes over time, without forcing password resets.

Resetting a password directly in the database#

Locked out of your own admin account? Generate a hash here and run the SQL shown under the tool:

sql
UPDATE users SET password = '$2y$12$…' WHERE email = '[email protected]';

Keep the hash inside single quotes: in many shells and some languages, $ inside double quotes is treated as a variable and the hash gets corrupted.

bcrypt or Argon2id?#

Both are good password hashes. bcrypt is supported everywhere and is the PHP default. Argon2id is the newer recommendation from security experts because it is also memory-hard, which makes GPU cracking much more expensive, and it has no 72-byte password limit. If your PHP supports Argon2id and all your servers do too, it is the stronger choice.

Laravel#

Laravel's Hash::make() uses password_hash() under the hood, with bcrypt and a cost of 12 by default (set by BCRYPT_ROUNDS). Switch to Argon2id in config/hashing.php with 'driver' => 'argon2id'. Hashes from this tool work with Hash::check().

Common errors and fixes#

  • password_verify() returns false for a correct password

    The most common cause is a column that is too short: a VARCHAR(50) cuts a 60-character bcrypt hash or a ~97-character Argon2id hash. Use VARCHAR(255). Also check the hash was not changed by $ being expanded in double quotes.

  • Fatal error: Undefined constant PASSWORD_ARGON2ID

    Your PHP was built without Argon2 support. Use PASSWORD_DEFAULT (bcrypt), or install a PHP build with libargon2 or libsodium.

  • Every hash of the same password is different

    That is correct: password_hash() adds a new random salt each time. Never compare hashes with ==; always use password_verify().

  • Logins got slow after upgrading to PHP 8.4

    PHP 8.4 raised the default bcrypt cost from 10 to 12, which is four times more work. It is safer; if your server struggles, pass ['cost' => 11] explicitly.

Frequently asked questions#

Can I use a hash from this page in my PHP app?

Yes. The hashes use exactly the same format as password_hash(), so password_verify() and Laravel's Hash::check() accept them.

What does PASSWORD_DEFAULT use?

bcrypt, producing $2y$ hashes. Since PHP 8.4 the default cost is 12; before that it was 10.

How long is a PHP password hash?

bcrypt hashes are 60 characters and Argon2id hashes are around 97 with the default settings. Store them in a VARCHAR(255) column so future algorithms also fit.

Do I need to store the salt separately?

No. The salt, algorithm and cost are all part of the hash string. password_verify() reads them from there.

Is it safe to enter a password here?

Everything runs in your browser and nothing is sent to a server. As a habit, still avoid typing passwords for important accounts into any website: use a temporary password and change it after logging in.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.