htpasswd generator
Create .htpasswd entries for Apache and Nginx HTTP Basic Auth. Choose
the APR1 (Apache MD5) crypt format used by htpasswd -m, or the SHA-1
{SHA} base64 scheme used by htpasswd -s, and copy the username:hash line
straight into your password file.
How it works
For APR1 the tool follows the published Apache algorithm exactly: it draws a
random 8-character salt, then runs a 1000-round MD5 key-derivation that repeatedly
folds the password and salt together, and encodes the result with Apache’s custom
base64 alphabet, producing $apr1$<salt>$<hash>. The salting and iteration make it
resistant to rainbow-table attacks, and a new salt each run means the same password
yields a different (still valid) hash every time. For SHA-1 it computes
{SHA} + base64 of SHA1(password) via the Web Crypto API — unsalted and therefore
deterministic.
Example
Username admin, password secret, APR1 scheme produces a line like:
admin:$apr1$Xy3kP9aZ$h0Q1m...
Add it to .htpasswd, then protect a directory:
AuthType Basic
AuthName "Restricted"
AuthUserFile /path/.htpasswd
Require valid-user
| Scheme | Format | Salted | htpasswd flag |
|---|---|---|---|
| APR1 | $apr1$… | Yes | -m |
| SHA-1 | {SHA}base64 | No | -s |
It is privacy-first: the password is hashed entirely in your browser and never leaves your device. Always serve Basic Auth over HTTPS.