SERVER TOOLS

Htpasswd Generator — Apache basic auth lines, generated locally

Create an Apache htpasswd entry using the APR1 MD5 algorithm entirely in your browser, with nothing sent over the network.

No colon character — the colon separates username from hash in the file format.
Shown in plain text on purpose so you can verify what you typed. It never leaves this page.
APR1 is salted and iterated. The SHA-1 option is unsalted and included only for legacy systems that require it.
Blank is filled with a random salt, and a fresh one is picked whenever the username or password changes. Typing your own salt (only useful for reproducing a known result) keeps it fixed.
One user per line. Append this to your existing file rather than overwriting it.
Hash algorithm
APR1
 
—
Salt
—
Hash rounds
—
Password length
—
Estimated entropy
Tip: APR1 uses MD5 with 1000 iterations. That is far stronger than a bare MD5 hash but much weaker than bcrypt, which Apache's htpasswd documentation describes as currently considered very secure. Treat basic auth as a light gate, not as protection for anything valuable.

An htpasswd generator produces the single line Apache needs to authenticate a user with HTTP basic authentication: a username, a colon, and a hashed password. Normally that line comes from the htpasswd command line utility, which is fine when you have shell access to the server and inconvenient when you do not.

The important thing about generating one in a browser is where the hashing happens. This page computes the hash locally in JavaScript. Your password is never transmitted, never logged, and never seen by any server, including ours. That matters because the alternative — pasting a password into a form that posts it somewhere for hashing — hands your credential to a third party before you have even used it.

What This Htpasswd Generator Does

Enter a username and password, and the tool produces a complete htpasswd line using the APR1 algorithm: MD5 applied over 1000 iterations with an eight-character salt, in the specific arrangement Apache's portable format defines. The output looks like user:$apr1$saltsalt$hashvalue and can be appended directly to a password file.

A SHA-1 option is included for legacy systems that require the older {SHA} format. It is unsalted, single-pass, and materially weaker — it is offered because some appliances and older configurations still accept nothing else, not because it is a reasonable default. The results panel shows the salt in use, the number of hash rounds, your password length, and an entropy estimate derived from the character sets present.

The tool also emits the matching Apache directives, because a password file with no configuration pointing at it does nothing. The paths and realm name in that block are examples; replace them with your own.

One behaviour to know about: the salt field fills itself with a random salt, and picks a new one whenever you change the username or password, so several users generated in one sitting each get their own salt. A salt you type yourself is kept until you clear it.

How to Use It

  1. Enter the username. Avoid colons, which act as the field separator in the file format.
  2. Enter the password. It is displayed in plain text so you can check it before committing to a hash you cannot reverse.
  3. Leave the salt alone unless you are reproducing a specific known hash. The page fills in a random one for you and replaces it whenever the username or password changes, so every line has its own.
  4. Copy the generated line and append it to your .htpasswd file. Each user gets one line.
  5. Add the configuration block to your Apache config, with AuthUserFile pointing at the absolute path of the password file. In a .htaccess file, use only the four lines inside the <Directory> block, because the wrapper is not valid there.

The Formula / How It's Calculated

APR1 is a variant of the older MD5-crypt scheme, adapted by the Apache Portable Runtime. It begins by hashing the password, the literal string $apr1$, and the salt together. A second hash of the password, salt, and password again produces an intermediate value, which is appended to the first context in 16-byte chunks until it has covered the password's length.

Then comes a deliberately awkward loop. The password length is walked bit by bit, appending either a null byte or the first character of the password depending on each bit. The result is hashed, and that hash is fed into a thousand further rounds in which the password, the salt, and the previous hash are combined in an order that changes according to whether the round number is odd, divisible by three, or divisible by seven.

The final sixteen bytes are re-ordered and encoded using a base-64 alphabet that starts with a dot and a slash rather than the standard one, producing the twenty-two character hash you see after the salt. All of that exists for one reason: to make each password guess expensive enough that testing a large dictionary takes meaningfully longer than a single MD5 would. The full algorithm is described in the Apache password formats documentation.

Be Clear-Eyed About What APR1 Protects Against

APR1 is not a modern password hash. MD5 is fast, and a thousand iterations is a small multiplier compared with what current hardware can attempt per second. Bcrypt, which Apache supports through the -B flag of the htpasswd utility, is designed to be slow in a tunable way, and Apache's htpasswd documentation describes it as currently considered very secure.

Bcrypt cannot be computed reliably in a browser without pulling in an external library, which would defeat the point of a page that makes no network requests, so this tool implements APR1 correctly rather than implementing bcrypt approximately. The honest framing: APR1 is appropriate for gating a staging site, a development environment, or an internal dashboard behind a shared credential. It is not appropriate as the only protection on customer data, payment functions, or administrative access to a production system.

If your password file is stolen, the strength of your password matters far more than the strength of the algorithm. A long random passphrase remains impractical to crack even under a fast hash; a dictionary word does not survive any hash function at all.

Why Basic Auth Needs HTTPS

HTTP basic authentication does not encrypt anything. It base64-encodes the username and password and sends them in a header on every single request. Base64 is an encoding, not a cipher — decoding it is a one-step operation with no key involved.

Over plain HTTP, that means the credential is readable by anything on the network path, and it is retransmitted with every image, stylesheet, and script the page loads. Over HTTPS the transport is encrypted and the exposure is limited to the endpoints. RFC 7617, which defines the scheme, says Basic is not a secure method of user authentication unless used with an external secure system such as TLS, because the password travels as cleartext, and that it SHOULD NOT be used to protect sensitive or valuable information without HTTPS.

Where the Password File Belongs

The most common deployment mistake is putting .htpasswd inside the web root. If the file is reachable by URL, anyone can download every hash in it and start cracking offline at their own pace, with no rate limiting and no logging. Placing it above the document root removes that possibility entirely.

File permissions matter too: the file needs to be readable by the web server user and by nobody else. And because the leading dot only hides the file from a casual directory listing on Unix-like systems, it provides no protection whatsoever from a direct request. If you genuinely cannot place the file outside the web root, an explicit deny rule for files matching the name is the minimum mitigation, but relocating it is the real fix.

Salts, and Why Two Users With the Same Password Look Different

The salt is eight random characters stored in plain sight inside the hash string. Its job is not secrecy — it is to make identical passwords produce different hashes. Without a salt, two accounts sharing the password letmein would produce byte-identical hashes, which tells an attacker instantly that cracking one breaks both, and allows precomputed rainbow tables to be used against the whole file at once.

With a per-user salt, every password must be attacked individually and precomputation becomes useless. This is exactly why the SHA-1 option in this tool is weaker than its digest length suggests: {SHA} entries carry no salt, so identical passwords produce identical hashes across every user and every server using the format. It is also why the Generate new salt button matters when you create several users in a row.

Managing More Than a Handful of Users

Basic auth has no password reset, no lockout after failed attempts, no session concept, no audit trail, and no way to revoke one person's access without editing a file. Every one of those is fine for three developers sharing a staging gate and unworkable for thirty people across two teams.

The signal that you have outgrown it is usually operational rather than technical: someone leaves and the shared password has to be rotated for everyone, or a person needs access to one path but not another. At that point the answer is an application-level login with per-user accounts, or an identity provider fronting the site, rather than a larger password file. Basic auth is a doorstop, and it works well as long as you remember that is what it is.

How to Read the Result

  • Hash algorithm and the line under it show which format you chose and the start of the generated line. The full line is in the htpasswd line box.
  • Salt is the eight characters between the second and third $ in an APR1 line. SHA-1 shows none. A salt you type that is shorter than eight characters is padded with random characters, and characters other than letters, digits, . and / are removed.
  • Hash rounds is 1000 for APR1 and 1 for SHA-1.
  • Password length counts characters. Estimated entropy multiplies the length by the size of the character pool it detects (lowercase, uppercase, digits, symbols). It assumes characters were chosen at random, so a memorable phrase or a dictionary word with a number on the end is much weaker than its score. Treat it as an upper bound.
  • The preset rows below were produced with the salts shown. The three APR1 lines were checked against OpenSSL's openssl passwd -apr1 with the same salt and matched. With a random salt your line will differ every time.
UsernamePasswordSaltGenerated lineLengthEntropy
webadminCorrect-Horse-42saltsaltwebadmin:$apr1$saltsalt$fjyHHt3/i2Vg18sa/8JFl.16105 bits
stagingletmeinabcd1234staging:$apr1$abcd1234$q78cFKfmrBsKC1O3O8hQP.733 bits
devhunter2Zz9./aB1dev:$apr1$Zz9./aB1$Rk4N8zRCbZGbAFoXBu7sw.736 bits
stagingletmeinSHA-1 option (no salt)staging:{SHA}t6h1/B6iKLkGEEG3zsS9PFKrPOM=733 bits
xCorrect-Horse-42abc (too short, padded with random characters)x:$apr1$abc.4yaR$xB5etwE8t03BtcgFsr6Bd0 (the padding changes every time)16105 bits

What to Do Next

  1. Copy the line into a new file outside the web root, for example /var/www/secure/.htpasswd, and set permissions so only the web server user can read it.
  2. Add the configuration block, change the directory path and AuthUserFile path to yours, then reload Apache.
  3. Open the protected URL over HTTPS and confirm the browser asks for the username and password. Try a wrong password too.
  4. For more users, change the username and password (a new salt is picked automatically) and append each new line.
  5. Use a long random passphrase. If the site holds anything valuable, move to per-user logins rather than a larger password file.
Need staging environments and production access set up properly?

Basic auth is a stop-gap, not a login system. If you want a private staging site set up as part of a website build, mention it when you contact Arb Digital.

Web Design Services Talk to Arb Digital

Common Mistakes to Avoid

  • Storing the password file inside the web root. If it can be fetched by URL, every hash in it can be attacked offline.
  • Using basic auth over plain HTTP. Credentials are only base64-encoded and are resent with every request on the page.
  • Reusing one salt for every user. Identical salts make identical passwords produce identical lines. This tool picks a new salt whenever the username or password changes; if you typed a salt yourself, clear it before the next user.
  • Overwriting the file when adding a user. Append the new line. If you use the command line utility, leave off the -c flag, which creates a new file and replaces an existing one.
  • Treating basic auth as real access control. There is no lockout, no audit trail, and no way to revoke one person without changing everyone's password.

Related Free Tools From Arb Digital

Write server rules with the htaccess redirect generator, and look up what a 401 or 403 from a protected path means in the HTTP status code lookup. The rest are in the free online tools hub.

Frequently Asked Questions

Is my password sent to a server by this tool?

No. The hash is computed in your browser with JavaScript and no network request is made. You can confirm this by disconnecting from the internet and generating a line anyway.

Which algorithm does this generator use?

APR1 by default, which is MD5 applied over 1000 iterations with an eight-character salt in Apache's portable format. A legacy unsalted SHA-1 option is also available.

Is APR1 secure enough for production?

It is far stronger than a bare MD5 hash but much weaker than bcrypt, which Apache's documentation describes as very secure. Treat it as suitable for gating staging and internal environments rather than protecting valuable data.

Where should the htpasswd file be stored?

Outside the web root, so it cannot be requested by URL, and readable only by the web server user. A leading dot in the filename provides no protection on its own.

Why does the same password produce a different hash each time?

Because the salt differs. This tool picks a random salt on load and a new one whenever the username or password changes (or you click Generate new salt). The htpasswd command line utility picks a new salt on every run. The salt is what stops identical passwords from producing identical hashes.

Can I add several users to one file?

Yes. Each user occupies one line in the format username, colon, hash. Append new lines rather than replacing the file.

Does basic authentication need HTTPS?

In practice, yes. The credential is only base64-encoded and is sent again with every request, so on plain HTTP it is readable by anything on the network path. RFC 7617 says Basic should not be used to protect sensitive information without HTTPS or a similar protection.

This tool generates password hashes for server configuration. It is not security advice — assess the sensitivity of what you are protecting and choose an authentication method that matches it.

Take it further

Want a fuller picture of your own site? Run the free AI Website Audit for a page-by-page report.