Runs in your browser. Your input is not uploaded.

htpasswd generator

Create Apache and Nginx htpasswd lines with bcrypt, and check a password against a line.

Loading the tool…

What it does, how to use it, and questions

What it does

An htpasswd file holds user:hash lines that Apache and Nginx use for HTTP basic authentication. The hash format decides how hard a stolen file is to crack.

bcrypt is the right choice: it is slow by design and supported by Apache 2.4 and Nginx on most Linux builds. Apache MD5 ($apr1$) is weaker and only for servers that cannot read bcrypt. {SHA} is a single unsalted SHA-1 and should not be used.

How to use it

  1. Enter a user name and password, or several on separate lines as user:password.
  2. Leave the format on bcrypt unless your server cannot read it.
  3. Copy the lines into your .htpasswd file, or use Verify to check a password against an existing line.

Example: bcrypt, cost 10

Input
admin / correct horse
Output
admin:$2y$10$…

Things to watch for

  • Basic authentication sends the password with every request, Base64-encoded but not encrypted. Only use it over HTTPS.
  • Nginx relies on the system crypt() for bcrypt. Some Alpine (musl) builds cannot read bcrypt; use Apache MD5 there and say so in your docs.
  • Keep the file outside the web root, or deny access to it, so it cannot be downloaded.

Guides

Questions

Is my password sent to the server?
No. Hashing happens in your browser with bcryptjs and Web Crypto. The old server endpoint has been removed.
How do I use this with Nginx?
Save the lines to a file such as /etc/nginx/.htpasswd and add auth_basic "Restricted"; and auth_basic_user_file /etc/nginx/.htpasswd; to the location block.
How do I use this with Apache?
Add AuthType Basic, AuthName "Restricted", AuthUserFile /path/to/.htpasswd and Require valid-user to the directory or .htaccess.
Why does the hash start with $2y$?
That is Apache’s marker for bcrypt, and what htpasswd -B writes. It is the same algorithm as $2b$.
Which bcrypt cost should I use?
10 to 12. Each step doubles the time per login. The server checks the hash on every request, so very high costs slow the site.