htpasswd Generator (apr1 / SHA-1)

Enter user:password pairs, one per line, and get .htpasswd entries hashed with apr1 (Apache MD5) or {SHA}, ready for basic authentication in Apache or nginx.

Use the tool

Why this tool exists

HTTP basic auth is still the quickest way to put a staging site or an admin path behind a password. Both Apache and nginx read the same .htpasswd format, but you need the htpasswd command to make it, and that is not installed on every laptop or CI image.

This tool builds the lines for you. The apr1 option gives the salted iterated MD5 format that htpasswd uses by default, and the SHA option gives an unsalted SHA-1 digest. Both are weak by modern standards, so prefer bcrypt where your server supports it, and use the separate bcrypt tool for that. Basic auth also sends credentials with every request, so serve it over HTTPS only.

How to use it

  1. Enter one user:password pair per line.
  2. Choose apr1 (MD5) or {SHA}, and optionally set a fixed salt for apr1.
  3. Copy the lines into your .htpasswd file and point the server config at it.

Frequently asked questions

Which algorithm should I choose?

apr1 is salted and iterated, so it is better than the SHA option, which is a single unsalted SHA-1. Bcrypt is stronger still; use the bcrypt generator if your server accepts it.

Is it safe to type real passwords here?

Hashing happens in your browser and nothing is sent, but treat any real password with care. Avoid reusing important passwords for basic auth, and prefer a long random one.

Why does the output change every time?

The apr1 format uses a random eight-character salt, so the same password gives a different line each time. All of them verify. Enter a salt yourself if you need a repeatable result.

Can a password contain a colon?

Yes. Only the first colon on a line separates the user name from the password, so the rest is taken as the password.