Skip to content
Accessibility
Theme
Text size
High contrast
Limit animations
Readable fontAtkinson Hyperlegible
Increased text spacing
Underline links
Always show focus

Runs in your browser — nothing you paste is uploaded.

htpasswd Generator

Make an .htpasswd line for Apache or nginx basic auth. Choose APR1 (Apache MD5) or SHA-1. Everything runs in your browser — the password never leaves this page.

APR1 uses a fresh random salt, so the line differs each time — that's expected.


    

What it does

Produces a single .htpasswd line of the form username:hash for HTTP Basic authentication in Apache or nginx. Type a username and password, choose the hash, and copy the result. If you leave the username blank it defaults to user. Everything is computed in the page — the MD5-crypt routine and base64 SHA-1 both run client-side.

Which algorithm?

APR1 is Apache's salted MD5-crypt ($apr1$salt$hash). It applies 1000 rounds of MD5 over the password and an 8-character random salt, so the same password hashes to a different line every time — that's the salt doing its job, not a bug. It is the classic, most widely supported htpasswd format and nginx understands it too. SHA-1 ({SHA}base64) is a single, unsalted SHA-1 — compact and simple, but with no salt and no work factor two identical passwords always produce the same hash, so it's the weakest option here.

For a new setup prefer bcrypt ($2y$…) where your server supports it — Apache's htpasswd -B or nginx with a bcrypt-aware build — because it has a tunable cost factor and resists brute-forcing far better than MD5 or SHA-1. This tool doesn't generate bcrypt; use it when APR1/SHA-1 compatibility is what you specifically need.

How to use

  • Create the file, e.g. /etc/apache2/.htpasswd, with one user per line. Paste each generated line in.
  • Apache: point a <Directory> or .htaccess block at it with AuthType Basic, AuthUserFile, and Require valid-user. See the .htaccess helper.
  • nginx: auth_basic "Restricted"; and auth_basic_user_file /path/.htpasswd; inside the location or server block.

Gotchas

  • Basic auth sends credentials base64-encoded, not encrypted — always serve the protected area over HTTPS or the password travels in the clear.
  • Because APR1 re-salts each time, don't be alarmed that re-generating gives a different line; any correct line will still authenticate the password.
  • MD5-crypt and especially unsalted SHA-1 are fast to brute-force. Use a long, random password (generate one with the Password generator) rather than a memorable word.

Privacy

Hashing runs locally; the username and password are never uploaded.

Frequently asked questions

Why does the line change every time I generate it?

APR1 uses a fresh random 8-character salt on each run, so the hash — and therefore the whole line — differs even for the same password. This is expected and improves security; any generated line will still verify the same password. Unsalted SHA-1, by contrast, is identical every time.

Should I use APR1, SHA-1, or bcrypt?

Use APR1 for maximum Apache/nginx compatibility, avoid plain SHA-1 since it is unsalted and weakest, and prefer bcrypt (via htpasswd -B or a bcrypt-aware nginx) for new setups because of its salt and tunable cost. This tool covers APR1 and SHA-1; bcrypt is generated by the server tooling.

Is HTTP Basic auth secure on its own?

Only over HTTPS. The browser sends the username and password base64-encoded on every request, which is trivially decoded, so without TLS the credentials are effectively sent in plain text. Always pair Basic auth with HTTPS and a strong, random password.

Related tools