Free · runs in your browser

Drupal Password Hash Generator

Drupal Password Hash Generator. Enter a password and click Generate Hash to produce a real Drupal 7 password hash. When your application expects a specific format, you can generate a password hash in several algorithms at once and copy whichever digest it needs.

Your values

Hashed in your browser only; nothing is uploaded. Use a temporary password and change it from your profile page after you log in.

Only used to write the WHERE clause of the SQL statement (the name column). Add your table prefix if the site uses one.

Drupal 7 keeps the hash in users.pass; Drupal 8 and later moved it to users_field_data.pass. Releases before 10.1 can only verify the $S$ format.

Drupal 10.1 and later verify bcrypt natively. A $S$ hash only verifies there while the Password Compatibility (phpass) module is enabled.

Used for $S$ hashes only. The count is stored in the hash, so any of them verifies on every Drupal version.

Result

Drupal password hash
—
SQL UPDATE statement
—
Hash format
—
Hash length (characters)
—
  • No account, no logging
  • Open formulas explained below
  • Works offline once loaded

When the reset email never arrives, a Drupal password hash generator is the fastest way back into a locked CMS, because Drupal never stores your password, only a salted hash of it. This guide shows what that stored value contains, how to produce a valid one, and how to write it into a user account so you can sign in again. The key rule: generate the hash with the same scheme Drupal itself uses.

Drupal Password Hash Generator Basics: What the $S$ String Holds

A password hash generator turns the text you type into the 55-character string saved in the database. The Drupal flavour starts with $S$, the marker that tells the core which scheme to apply when someone signs in. It has been the default from Drupal 7 through Drupal 10, so one hash format covers every supported release, and a value written today still verifies after an upgrade. Hash the password concatenated with the username in the free postgres md5 password hash generator to get the pre-encoded value for pg_authid.

Iterated SHA-512 formula for a Drupal hash with a bar chart comparing bcrypt, Drupal and WordPress hash lengths
The iterated SHA-512 formula and how the stored hash length compares with bcrypt and WordPress.

You will want a generated value in three situations: a restored copy of the site with no known admin password, a host that offers no shell, and the migration of accounts from another site. In each case the generator gives you the exact $S$ string Drupal expects. Treat that output as security-sensitive, because it unlocks accounts, and keep it out of tickets and chat logs. Quick, accurate recovery work like this is where the tool earns its place.

How Drupal Password Hashing Works: SHA-512, Bcrypt and Salt

Drupal's password hashing is a variant of phpass. The core joins a random salt to your plaintext password, runs the result through SHA-512, and then repeats that step over the output so that every guess costs an attacker real time. A hash is one-way, so unlike encryption nothing can be decrypted later; any module that chooses to encrypt stored hashes only adds a wrapper around them. Choose uppercase or lowercase hex, or base64, in the sha256 hash generator to match what an API or build log shows.

Bar split into the $S$ marker, D cost character, 8-character salt and 43-character digest of a 55-character Drupal password hash
The four parts of the example Drupal password hash: marker and cost, salt, and truncated SHA-512 digest.

When someone signs in, Drupal hashes what the visitor typed with the stored salt and runs a time-safe comparison against the saved value. If the hashing subsystem sees an older scheme or a weaker setting than the current one, it will rehash the password and save the improved value for next time.

How Drupal Password Hashing Works: SHA-512, Bcrypt and Salt
SourcePrefixAlgorithmSalt
Drupal core, versions 7 to 10$S$DIterated digest, same family8 random symbols inside the string
Optional bcrypt setup$2y$Native password_hash callGenerated per account

Phpass Rounds and the Hash Format

The characters after $S$ follow a fixed pattern: one symbol for the cost factor, eight random symbols, then the encoded digest. A D means 215, which is 32,768 rounds, iterated once per round. The digest is truncated so the full string always totals 55 symbols, so a longer-looking value pasted into a field is a warning sign.

As a worked check, the password Harbor-Lamp-4471 with the eight symbols kQ7mWx2R yields $S$DkQ7mWx2RzDVRoDjVBW83eAXvt0cHurI6hTybQbWJfin5bl9Rea3. Change one character of the password and every symbol after the eight random ones changes.

Argon2i and the Hashing Algorithm Switch

On Drupal 7, the PHP Native password_hash module lets you replace the standard hashing algorithm with bcrypt or Argon2i. The newer option needs version 7.2 of the language or newer, and the module still verifies old hashes, so existing accounts keep working while new ones move to the stronger scheme.

Hashing Options in settings.php

The module needs no configuration after installation. If you want different hashing options, they live in settings.php: you can raise the cost factor, or set memory, time and thread costs. Keep that configuration conservative and test it on a staging copy first, because each increase makes every sign-in slower, and a value that is too high can slow a busy site to a crawl. A sensible habit is to change one value at a time and time a single sign-in before and after.

Resetting a Locked-Out Admin Login with a Hash Script

If you are locked out and have database access but no shell, a short hash script or online generator plus one SQL change is enough. Work through it in this order:

  1. Take a backup of the user table before touching anything.
  2. Choose a new plaintext password and generate the $S$ value for it.
  3. Find the admin account row, which should carry the administrator role among its roles.
  4. Run the SQL statement below, then sign in with the new password.

Writing the UPDATE Statement for users_field_data

Paste the generated $S$ value into the pass column. Drupal 8 and later keep accounts in a different table from the older release, which used the plain users table, and the update statement only sets that one column:

UPDATE users_field_data SET pass = '$S$DkQ7mWx2RzDVRoDjVBW83eAXvt0cHurI6hTybQbWJfin5bl9Rea3' WHERE uid = 1;

Filtering by uid keeps the new value on one account, and writing it to the wrong column or table simply leaves you locked out.

Two details trip people up. First, copy the value exactly: a trailing space or a shell that expands the dollar signs inside the quotes silently corrupts it, and the sign-in then fails with no useful error. Second, clear Drupal's caches after the change if the site sits behind a page cache, so the next attempt reaches the live record rather than a stale copy.

Rebuilding an Admin Login with a Drupal Password Hash

Dana restores a staging copy of a client's Drupal 10 site from a backup and finds nobody knows the admin password. The goal is simple: get into account uid 1 without touching the live server. Shell access is blocked by the host, so she goes the manual route, with the chosen password Cedar-Wren-8206! and the random symbols pT3vL9aZ.

Timeline of where Drupal 7, 8, 10.1 and 11 store the password hash and which format each uses
Which table and hash format each Drupal version uses.

Running the scheme at the standard cost of D (215 rounds) gives $S$DpT3vL9aZnCCuvITdZoKJYZUMcTvDfhVeqDpyBZNnP.LVSgscEWy. Her cross-check is mechanical: the string starts with $S$D, is exactly 55 symbols long, and matches the pattern in Drupal's own reference script. Only then does she paste it into the update statement for uid 1 and sign in.

Rebuilding an Admin Login with a Drupal Password Hash
Cost symbolRoundsTime for one hash on a laptop
D32,768about 16 ms
E65,536about 24 ms
G262,144about 76 ms

She also reruns the generator with E and G to see what a heavier setting costs. The number to watch is the time per sign-in: at G, a site handling 50 sign-ins a second would spend almost four seconds of CPU every second on hashing, which is why the default is a sensible ceiling for most sites, and why she keeps D.

One edge case catches her. Drupal accepts only a cost between 7 and 30, so a hash carrying a symbol outside that range is rejected outright; hand-editing the fourth symbol to "tune" it does nothing useful. Her next step is a named one: after signing in, she resets the password from the admin screen, so that the value pasted into the team chat during the recovery is no longer valid anywhere.

Drush and password-hash.sh in the Shell

With shell access, skip the manual route: drush user:password admin "new-password" changes the password with the site's own code. Drupal core also ships core/scripts/password-hash.sh, which prints a hash for any quoted password you pass it, using the same kernel your site runs. Because both use the real container, there is no chance of picking the wrong column or scheme.

Whichever route you choose, never type a live production password into a third-party site. Generate a throwaway value, apply it, and change it from the admin screen as soon as you are in. Installing helper modules through Composer is rarely necessary for this task.

If you inherit a site and are unsure which route fits, ask one question: can I run commands on the server? If yes, use the shell and let the site compute its own value. If no, the manual route above is safe as long as the backup exists, the string is exactly 55 characters long, and the statement targets one row.

Frequently Asked Questions

Does this match Drupal 8, 9, or 10's password hashes?
No -- Drupal 8 and later switched to PHP's built-in password_hash() function, which uses bcrypt by default. That's exactly what this site's Bcrypt Generator produces, so use that tool instead if you're targeting Drupal 8+. This tool specifically replicates Drupal 7's own $S$-prefixed scheme.
How does Drupal 7's algorithm work?
It's structurally the same "stretched hash" approach as the classic phpass library (the same design WordPress's legacy $P$ hashes use), but with SHA-512 as the underlying hash instead of MD5: the password is combined with a random salt and hashed repeatedly (2^15 = 32,768 times by default), then the result is encoded with a custom base64-like alphabet and truncated to Drupal's fixed 55-character hash length.
How was this verified to be correct?
By fetching Drupal core's actual includes/password.inc source directly from Drupal's own GitHub repository and implementing the documented algorithm exactly as specified -- including a detail easy to get wrong (the full SHA-512 output is base64-encoded to 86 characters, then the combined string is truncated to exactly 55 characters, not encoded to 55 directly). Cross-checked byte-for-byte between an independent Python re-implementation and this tool's actual browser JavaScript before shipping.
Can I insert this hash directly into a Drupal database?
Yes -- the generated string matches the exact format Drupal 7's users table pass column expects, so it can be used directly in a manual database update or migration script for a Drupal 7 site.
Is my password sent anywhere?
No. The entire hash is computed locally using the Web Crypto API -- your password and the resulting hash are never transmitted to a server or stored.

About the author

Vinitha Pu

Founder and designer

Vinitha Pu is a graphic designer based in Palakkad, Kerala, who builds free, privacy-friendly browser tools. She studied Textile and Apparel Design at Avinashilingam University and completed a C-Tech in Graphic Design at Image Creative Education in 2025. She designs, builds and maintains the password generators, strength checkers, hash tools and security calculators on PasswordHive.

  • Content author: Vinitha Pu
  • Fact checked by: Vinitha Pu. Each tool's output is checked against official test vectors or a reference implementation, and every strength and crack-time figure against the formula it uses, before it goes live.
  • Published Updated