Make an htpasswd entry

Create a user:hash line for an Apache or nginx password file in Apache's default $apr1$ MD5 format, or SHA-1.

Make an htpasswd entry

0 characters

Three steps — nothing to install

  1. Type a user name and password

    Both stay in this tab; nothing is sent or stored.

  2. Pick the format

    Apache MD5 ($apr1$) is the default; SHA-1 is available for older setups.

  3. Copy the line

    Append it to .htpasswd and point the AuthUserFile directive at that file.

What $apr1$ is

Apache's htpasswd has used several formats. The default for htpasswd -m is a salted MD5 variant tagged $apr1$, which is not the same as a plain MD5 hex digest: it iterates the hash a thousand times with the salt and a magic prefix. That is why you cannot produce a valid line by hashing the password once.

The output is user:$apr1$salt$hash. The salt is random for every run, so the same password gives a different line each time, which is correct — and means you cannot compare two lines to see whether the passwords match.

Why bcrypt is missing

bcrypt is the better choice for a password file: it is deliberately slow, so a stolen file is expensive to attack. Doing it properly needs a native library or a WebAssembly build of the algorithm, and this page does not ship one. Offering a weak imitation with the same name would be worse than saying no.

If the server supports it, generate the line on the server with htpasswd -B, or use the bcrypt module of nginx's auth_basic. Use this page when you need an $apr1$ line and have no shell access — for example on shared hosting where the password file is edited by upload.

File permissions and verification

The .htpasswd file must be readable by the web server and not by the public. Put it outside the document root if you can; if it must live inside, deny access to it in .htaccess with a <Files> block. A password file served as plain text defeats the point.

To check a line, use htpasswd -vb .htpasswd user password on the server, or open the protected URL in a private window. One user per line; add more lines for more users. For other hashing needs, the hash generator covers SHA-256 and friends.

Frequently asked questions

Can I generate a bcrypt line?No. bcrypt needs a native or WebAssembly implementation that this page does not ship. Use htpasswd -B on the server.
Is $apr1$ secure?It is far better than plaintext and weaker than bcrypt. It is Apache's default and what most hosts expect.
Can I add more users?Yes. Append another line per user; the file holds one entry per line.
How do I verify the line?Use htpasswd -vb on the server, or open the protected URL in a private window.
Is my password uploaded?No. The hash is computed in this tab and the value is not stored anywhere.
Why is the output different each time?The salt is random for every run, which is how salted hashes should behave.