admin@likeapro.dev: ~/htpasswd — zsh

// admin tools · 05

htpasswd forge

Build a basic-auth .htpasswd file for Apache or nginx with bcrypt, APR1-MD5 or {SHA}, grab the matching server config, and hash or verify bcrypt strings at any cost.

// runs locally — passwords are hashed in this tab, nothing is uploaded

hash

4–14

Not offered: crypt() DES (only the first 8 characters count) and plaintext — both are trivially recoverable.

users

.htpasswd


                        

server config

nginx


                            

apache .htaccess


                            

shell equivalents


                        

Basic auth sends the password with every request — serve it over HTTPS only, and keep the file outside the web root.

HTPASSWD local only · 0 bytes sent --:--:--

How it works

What it does

This tool builds the user:hash lines that Apache and nginx read for HTTP basic authentication, then gives you ready-to-paste server config that points at the file. Add as many users as you need, pick a hash, and download the finished .htpasswd. The --bcrypt tab hashes any text at a chosen cost and shows how long it took; --verify checks a password against an existing hash.

Hashing happens in your browser. bcrypt uses the vendored bcryptjs 2.4.3 library through its asynchronous API, so the page stays responsive at high cost factors. APR1-MD5 is implemented in this page and self-tests against a known Apache output on load. Salts come from crypto.getRandomValues. Nothing is uploaded.

Which hash to choose

bcrypt $2y$
Deliberately slow and salted. Supported by Apache 2.4.4 and later. nginx passes anything that isn't $apr1$ or {SCHEME} to the operating system's crypt(), which handles bcrypt on Linux distributions that ship libxcrypt (most current ones). Test before you rely on it.
APR1-MD5
Apache's variant of MD5-crypt: a random 8-character salt and 1,000 MD5 rounds. Works on every Apache and nginx build, but it is fast enough to brute-force on modern GPUs.
{SHA}
One unsalted SHA-1 of the password, base64-encoded. Equal passwords produce equal hashes. Only for legacy software that accepts nothing else.

Plaintext and traditional DES crypt() are not offered. DES crypt silently ignores everything after the eighth character.

The bcrypt cost factor

The cost is a base-2 exponent: cost 10 runs 210 key-expansion rounds, cost 11 twice as many. Higher costs slow attackers and your own server by the same factor, because the server hashes the password on every request with basic auth. Cost 10 to 12 is a sensible range. bcrypt only reads the first 72 bytes of a password, and the tool warns you when you go past that.

Deploying the file

  1. Save the download as .htpasswd somewhere outside the document root, such as /etc/nginx/.
  2. Make it readable by the web server only, e.g. chown root:www-data and chmod 640.
  3. Add the nginx or Apache snippet, test the config (nginx -t or apachectl configtest), then reload.

FAQ

What's the difference between $2a$, $2b$ and $2y$?

They're the same algorithm. $2y$ marks hashes from the fixed crypt_blowfish code (PHP, Apache), and $2b$ is OpenBSD's marker for its 2014 fix. For ordinary passwords (ASCII, under 255 bytes) all three produce the same hash body, and most libraries accept all three when verifying.

Is basic auth secure?

Only over HTTPS. The browser sends the username and password, base64-encoded but not encrypted, with every request. There is no lockout either, so use long random passwords. The random button makes 20 characters, about 116 bits.

Can I add a user to an existing file?

Yes. Each line stands alone, so you can append the generated line to your existing file. If a username appears twice, the server uses the first match.