Tools / htpasswd Generator

htpasswd Generator.

Create .htpasswd lines for Apache and Nginx basic auth with bcrypt, Apache MD5 (apr1) or SHA-1.

Runs in your browser

Each step doubles the work. 10 takes well under a second in a browser.

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
.htpasswd line
Details

About htpasswd Generator

The htpasswd generator produces the user:hash line that Apache's AuthUserFile and Nginx's auth_basic_user_file expect, without installing apache2-utils or httpd-tools. Enter a user name and a password, choose the hash and paste the result into your .htpasswd file, one user per line. bcrypt is the default and the right choice for anything new: it is salted and deliberately slow, and the cost setting doubles the work for every step; Apache 2.4 and Nginx with a modern libc both accept the $2y$ format it outputs. Apache MD5, written as $apr1$, is the traditional htpasswd -m format with an 8-character salt and 1,000 MD5 rounds; it works everywhere, including old Nginx builds, but is far quicker to brute-force. {SHA} is an unsalted SHA-1 digest kept only for legacy servers. For example, user admin with bcrypt cost 10 yields a line such as admin:$2y$10$…, 60 characters after the colon, and each run produces a different hash because the salt is random — that is expected, and all of them verify. Typical mistakes: a colon in the user name (it separates the fields), Windows line endings in the file, the file being readable by the web server's public document root, and expecting bcrypt to use more than the first 72 bytes of a long password. The details panel also shows the equivalent htpasswd command. Hashing happens in your browser and the page is marked sensitive, so the password never reaches a server or the address bar.

How to Use

  1. Enter the user name and password.
  2. Choose bcrypt (recommended), apr1 or SHA-1, and the bcrypt cost.
  3. Copy the line into your .htpasswd file and reload the web server.

Frequently Asked Questions

Which algorithm should I use?

Use bcrypt. Choose apr1 only for software that does not understand bcrypt, and SHA-1 only for very old servers. Plain-text and DES crypt are not offered because they are insecure.

Why is the hash different every time?

Each hash uses a new random salt, so the same password gives different lines. The server reads the salt from the hash, so every version verifies correctly.

Does Nginx support bcrypt in htpasswd files?

Nginx uses the system crypt() function. Most current Linux distributions support $2y$ bcrypt; if yours does not, use apr1, which Nginx implements itself.

Is the password sent to a server?

No. The hash is computed in your browser and the password is never uploaded, logged or stored in the URL.

Related Tools