htpasswd Generator

htpasswd Generator

Create a .htpasswd line with the Apache apr1-MD5 hash. Enter a username and password, and get a line you can add to your .htpasswd file.

The password is hashed in your browser and never sent anywhere. apr1-MD5 is a legacy format kept for compatibility with Apache and Nginx; for new setups, prefer bcrypt where your server supports it.
Your line will appear here.

Add the line to your .htpasswd file, one user per line. Each run with a random salt gives a different hash for the same password, which is expected.

About the htpasswd Generator

An htpasswd generator makes a line for an Apache .htpasswd file, in the form username, colon, then a password hash. A .htpasswd file is a plain text file that stores usernames and password hashes for HTTP Basic Authentication, the login box a browser shows before a protected page loads. Apache and Nginx both use it to protect a directory or a whole site.

This tool creates the line with the apr1-MD5 format, the Apache format written as $apr1$. The apr1 algorithm is MD5-based, with a salt and 1,000 rounds, followed by a custom base64 encoding. The salt is stored inside the hash itself, so the server can check a password against it later. To generate htpasswd lines for an older server that only reads apr1, or to make htpasswd entries that match an existing file, this is the format to use.

Everything happens in your browser. The password is hashed on your own device and is never sent anywhere, so you can use this htpasswd generator on a live password without worrying about it travelling over the network.

How to use

  1. Enter a username. It must not contain a colon, because the colon separates the username from the hash in the file.
  2. Enter a password. Use a long password with letters, digits, and symbols.
  3. Leave the salt blank for a fresh random salt, or enter your own 8-character salt to reproduce a known hash.
  4. Click Generate htpasswd line, then Copy line and paste it into your .htpasswd file, one user per line.
  5. Tick Show password if you want to check what you typed before you generate the line.

Key features

  • Correct Apache apr1-MD5 hashing with 1,000 rounds
  • Random salt generation from the browser crypto source, with a New random salt button
  • Option to enter a fixed 8-character salt for testing or reproduction
  • Show password checkbox so you can check your typing
  • Copy to clipboard in one click, plus a Clear button
  • Hashing runs locally; the password never leaves your browser

Common uses

Use this tool to password-protect a staging site, an admin folder, or a private download area on Apache or Nginx. It is also handy when you move a site to a new server and need a fresh .htpasswd line that matches the old format, or when you are testing Basic Authentication and need a known line to check against.

Frequently asked questions

What is a .htpasswd file?

A .htpasswd file is a plain text file that holds one user per line, each line in the form username:hash. Apache and Nginx read it when a directory is protected with HTTP Basic Authentication, and the browser asks the visitor for a username and password before showing the page.

Why does the same password give a different line each time?

Each run draws a fresh random salt, and the salt changes the hash. That is by design: it stops two accounts with the same password from having the same hash.

How can I check the hash is correct?

Enter the salt xxxxxxxx and the password password. The tool must produce alice:$apr1$xxxxxxxx$dxHfLAsjHkDRmG83UXe8K0 when the username is alice. That is the known test vector for apr1.

Is apr1-MD5 still safe?

It is a legacy format. It is widely supported by Apache and Nginx, but modern hardware can test MD5-based hashes quickly, so prefer bcrypt for new setups where your server supports it.

Can I use the line on Nginx as well as Apache?

Yes. Nginx reads the same .htpasswd format for Basic Authentication, and an apr1-MD5 line works on both servers.

Where should I store the .htpasswd file?

Keep it outside the public document root, so it cannot be downloaded through the web, and serve the protected pages over HTTPS so the username and password are not sent in plain text.

How do I use the htpasswd generator?

Enter a username and a password, leave the salt field blank for a fresh random salt, then click Generate htpasswd line. Copy the finished line and paste it into your .htpasswd file on the server.

Why can my username not contain a colon?

The colon separates the username from the password hash in the .htpasswd line, so a colon inside the username would break that format. Use letters, numbers, and other characters instead, and keep the colon out.

What is the salt field for, and can I leave it blank?

The salt is a random value mixed into the hash so the same password produces a different line each time. Leave the field blank for a fresh random salt, or enter your own 8-character salt if you need to reproduce a known hash.

Is my password sent anywhere when I generate the line?

No, the password is hashed on your own device in the browser and is never sent over the network. You can safely use it with a live password.

What do I do with the line after I copy it?

Paste it into your .htpasswd file on the server, with one line per user, and point your server configuration at that file. The server then shows visitors a login box before the protected page loads.

Free to use, no signup needed. This tool runs entirely in your browser — your data never leaves your device.