Htpasswd Generator

Generate an Apache htpasswd entry for HTTP Basic Authentication.

100% Free · No Sign-up · Runs in Your Browser

About the Htpasswd Generator

Apache's .htpasswd file stores usernames and hashed passwords used for HTTP Basic Authentication, protecting a directory or admin area with a simple login prompt at the web server level. This generator creates a correctly formatted htpasswd entry from a username and password, entirely in your browser, without needing the Apache htpasswd command-line utility installed locally.

This tool is useful for developers and sysadmins setting up basic password protection for a staging site, admin panel, or internal tool, anyone without command-line access to their server who still needs to generate a valid htpasswd entry, and DevOps engineers scripting server configuration who need a quick reference entry to test with.

To use it, enter a username and password, choose a hash format (bcrypt is recommended for modern Apache versions, while MD5 (Apache-specific apr1 format) and SHA-1 remain available for compatibility with older systems), and the tool generates the exact line to add to your .htpasswd file, in the format username:hashedpassword.

For example, generating a bcrypt entry for username "admin" produces a line like "admin:$2y$10$KIXQ..." — this exact line should be pasted into your server's .htpasswd file (referenced by an AuthUserFile directive in your Apache configuration or .htaccess file), after which visitors will be prompted for that username and password before accessing the protected directory.

A common mistake is choosing an outdated hash format unnecessarily — bcrypt is the modern, recommended choice for new setups since it's designed to be computationally slow (resisting brute-force attacks), while older formats like plain MD5 or SHA-1 are faster to compute and therefore more vulnerable to being cracked if the file is ever exposed; only use those older formats specifically when required for compatibility with an older Apache version that doesn't support bcrypt. Another frequent issue is forgetting that HTTP Basic Authentication alone sends credentials with only base64 encoding (not encryption) unless the connection is also secured with HTTPS — always serve any password-protected directory over HTTPS, since Basic Auth credentials sent over plain HTTP can be easily intercepted.

Tip: for multiple protected users, generate each username/password entry separately and add each as its own line within the same .htpasswd file — Apache reads every line in the file as a separate valid user credential.

Frequently Asked Questions

Q.Which hash format should I use?

Bcrypt is recommended for modern Apache installations since it's specifically designed to resist brute-force attacks; use MD5 or SHA-1 only for compatibility with older server setups.

Q.Is Basic Authentication secure on its own?

Credentials are only base64-encoded, not encrypted, so always serve any Basic Auth-protected directory over HTTPS to prevent interception.

Q.Where do I add the generated line?

Add it to your .htpasswd file, referenced by an AuthUserFile directive in your Apache configuration or a .htaccess file.

Q.Can I add multiple users to one htpasswd file?

Yes, generate a separate username:hash entry for each user and add each as its own line in the same file.

Q.Is my password sent to a server to generate the hash?

No, hashing happens entirely in your browser using JavaScript; your password is never transmitted.

Related Tools