1. Home
  2. Developer
  3. htpasswd Generator

htpasswd Generator

Create .htpasswd hashes for several users and verify existing ones.

For every format and option in one place, use Server Config Generators →

Runs in your browser · No upload
Every +1 doubles the time. 10 takes roughly 0.1 s per user. The default of htpasswd -B is 5.
A username cannot contain a colon (:), a password can. Up to 100 users. The box holds a sample.

Enter users and press Generate.

Basic auth sends the password with every request in nearly plain form (base64). Use it only over HTTPS.

Passwords you type and the hashes made from them are computed only in this browser and never sent to a server.


Check an existing hash

How to use

  1. Enter users as “user:password”, one per line. The two lines already in the box are a sample: replace them with your real users.
  2. Pick a hash method. Unless you have a reason not to, use bcrypt. With bcrypt you can also set the cost (4 to 12).
  3. Press “Generate .htpasswd” to get user:hash lines. Copy them or download a .htpasswd file and upload it to your server.
  4. To check whether a hash you already have matches a password, use “Check an existing hash” below.

Comparing the methods

Method Hash looks like Notes
bcrypt $2y$10$... Has a salt and a cost factor, the safest choice. Same $2y$ format as htpasswd -B, read by Apache 2.4 and nginx
MD5 (apr1) $apr1$salt$... Apache’s MD5 variant with a salt and 1000 rounds. Compatible with old setups but a fast hash and therefore weak
SHA-1 {SHA}... No salt, so equal passwords give equal hashes. Use only when compatibility demands it

Each +1 of bcrypt cost doubles the work. The maximum here is 12; in a desktop browser cost 10 took roughly 0.1 s per user and cost 12 roughly 0.4 s, depending on the device. The server repeats the same work on every login, so a very high cost can slow it down. Only the first 72 bytes of a password count; a longer one triggers a warning.

Applying it on the server

nginx:

location /admin/ {
  auth_basic "Restricted";
  auth_basic_user_file /etc/nginx/.htpasswd;
}

Apache (.htaccess or a virtual host):

AuthType Basic
AuthName "Restricted"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user

Keep the .htpasswd file outside the web root and readable only by the web server account. If it can be downloaded over the web, the hashes are exposed. You can build a full nginx configuration with the nginx config generator.

Things to keep in mind

  • Basic auth sends the username and password on every request with only base64 around them. Use it over HTTPS only.
  • Make long random passwords with the password generator so they hold up even if the hash file leaks.
  • All computation happens in this browser; passwords and hashes are never sent to a server.
  • Old formats such as DES crypt are not supported.

FAQ

How do I create an htpasswd file?

Enter the users and passwords in this tool and you get user:hash lines. On a server you can run htpasswd -c -B .htpasswd alice instead; the output has the same format.

Can nginx read bcrypt hashes?

nginx relies on the system crypt(). $2y$ bcrypt and $apr1$ are read on typical Linux systems, but this depends on the environment, so test a login after configuring it. {SHA} works too.

The hash is different every time I generate it. Is that right?

Yes. bcrypt and apr1 add a random salt each time, so the same password produces a different hash on every run and any of them works for logging in. SHA-1 has no salt and is always the same.

Can an existing hash be turned back into the password?

No. Hashing is one-way. “Check an existing hash” runs the same computation on the password you type and compares the result.

I want to compute a hash by hand.

General SHA hashes are available in the hash generator. Note that {SHA} in an .htpasswd is the SHA-1 digest written in base64.

Users and passwords you enter are processed only in your browser and never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.