Htpasswd Generator Online — Create .htpasswd Files With Bcrypt & MD5

CodexFuse Team · 2026-10-14T03:35:28.103Z · 6 min read min read

Generate secure .htpasswd files with bcrypt in seconds. Learn setup on Apache and Nginx, plus the mistakes that leave folders unprotected.

An htpasswd generator is a free online tool that creates the username-and-password entries for an .htpasswd file, the credential file Apache and Nginx use for HTTP Basic Authentication. Instead of hand-crafting hashes in a terminal, you type a username and password, choose a hashing algorithm such as bcrypt, and the tool returns a ready-to-paste line like admin:$2y$10$...

If you need to password-protect a staging site, an admin folder, or a private download area, this is the fastest safe way to do it. In this guide, you will learn exactly how an htpasswd generator works, which hashing algorithm to choose, how to wire the file up on Apache and Nginx, and the mistakes that leave protected folders wide open.

What Is an Htpasswd Generator?

An htpasswd generator is a web tool that takes a username and a plain-text password and outputs one line for an .htpasswd file, with the password converted into a one-way hash. The server stores only the hash, never the real password, and checks each login attempt by hashing what the visitor types and comparing the result.

What one output line contains

The output follows a simple format. The username sits in plain text before a single colon, and the password hash follows after it. One line equals one user. Need five logins? Generate five lines and stack them in the same .htpasswd file. The web server reads the file on every login attempt and grants access only when the supplied credentials match a line in it.

Traditionally, creating this file meant connecting to a server and running Apache's htpasswd command-line utility. That still works, but it assumes you have shell access, the utility installed, and the confidence to pick the right flags. A browser-based generator gives the same result with none of that friction.

How Does .htpasswd Authentication Work?

When a visitor requests a protected directory, the server answers with a 401 status and asks the browser to show a login prompt. The visitor types a username and password, the browser sends them back, and the server hashes the password and compares it with the stored hash before granting or refusing access.

The request flow in four steps

First, the browser requests a protected page. Second, the server refuses with a 401 status and a request for credentials. Third, the browser shows a login box, and the visitor enters a username and password. Fourth, the server checks the entry against the .htpasswd file. If it matches, the page loads.

Basic Authentication sends credentials with every request, so it must run over HTTPS, where the connection is encrypted. Over plain HTTP, the credentials travel in a form any network observer can read. For the header format itself, see the basic auth generator, which builds the Authorization header that browsers and scripts send with each request.

Which Hashing Algorithm Should You Choose?

Choose bcrypt for new .htpasswd files, because it is slow by design and resists guessing attacks far better than older hashes. MD5-based hashes from the older apr1 format still work on legacy setups, but they are weaker and should only remain where an old server cannot support bcrypt. For the full rundown, see AI Event Invitation.

Bcrypt first, MD5 only for legacy servers

Bcrypt includes a cost factor that controls how much work each check takes. A cost of 10 is a common default, and raising it makes guessing slower at the price of a little more server work per login. The CodexFuse htpasswd generator offers bcrypt and MD5, so you can match the format your server expects. Pick bcrypt unless you have a specific legacy reason to pick MD5, and plan to move legacy entries to bcrypt when the server allows it.

The hash is only as strong as the password behind it. A short or common password falls quickly no matter which algorithm you pick, because attackers try the obvious candidates first. Use a long, random password for every folder, and store each one in a password manager.

How Do You Set Up .htpasswd on Apache and Nginx?

On Apache, save the generated line in an .htpasswd file outside the public web folder, then point an .htaccess file or virtual host block at it with AuthUserFile. On Nginx, save the same file and add auth_basic and auth_basic_user_file to the location block, then reload the server.

Apache setup

Create the .htpasswd file in a folder the web cannot serve directly, such as one level above the site root. In your .htaccess file or virtual host, add AuthType Basic, AuthName with a short label, AuthUserFile with the full path, and Require valid-user. Test in a private browser window, and confirm that the wrong password is refused before you treat the folder as protected.

Nginx setup

Nginx has no .htaccess, so the protection lives in the server block. Inside the location you want to guard, add auth_basic with a short label and auth_basic_user_file with the full path to the .htpasswd file, then reload Nginx and test. Password protection is one layer only; pair it with HTTPS and the rest of the habits in the small business cybersecurity guide to cover the basics.

Mistakes that leave folders open

The classic mistake is storing the .htpasswd file inside the public folder, where anyone can download it. Another is forgetting to reload the server after editing the config, so the old open behavior stays live. A third is protecting one folder while leaving a copy of the same content in an unguarded path.

Locking down a staging site is one task. CodexFuse is an all-in-one managed IT platform on pay-as-you-go credits. One team handles your hosting, security, and support, so you can focus on the work itself.

Frequently Asked Questions

Can I use one .htpasswd file for several folders?

Yes. Point each folder's config at the same file, and the same usernames work everywhere it applies. For separate teams, use separate files so each folder has its own list of users. Find hundreds more practical how-tos on our blog.

Is Basic Authentication safe on its own?

Only over HTTPS. Without encryption, credentials travel in a readable form. With HTTPS, a strong password, and a current server, it is a sound layer for staging areas and private folders.

What do I do if I forget the password?

Generate a new line with the same username and a new password, then replace the old line in the .htpasswd file.

Should I use MD5 or bcrypt for a new site?

Use bcrypt. MD5-based apr1 hashes exist for old servers that cannot support bcrypt, but they are weaker. For any new setup on a current server, bcrypt is the right choice.

Can I manage protected folders without touching a server?

Yes. If server work is not your job, a managed host can set up and watch the protection for you. See the managed VPS hosting guide for a setup where the server work is handled.

Can an htpasswd generator create a file with several users?

Yes. Add one user at a time — the generator keeps every line in a list until you are done. Then use Download .htpasswd to save all the lines as one file, or Copy All to paste them into an existing file. Usernames may only use letters, numbers, dots, underscores and dashes: a colon is not allowed because it separates the username from the hash in the file.

Which hashing algorithms does this htpasswd generator support?

It generates MD5 (apr1 — the default, Apache’s classic $apr1$ format) and SHA-1 ({SHA}) lines. For bcrypt, generate the line with the htpasswd -B command on the server and paste it into the same file — a single .htpasswd file can mix formats, because each line’s prefix tells the server which algorithm to verify against.

Generate your line with the htpasswd generator, save the file outside the public folder, and test both the right and the wrong password. A folder you have tested is a folder you can trust.

Featured on Twelve Tools Hunt for Tools Featured on LaunchBuff Launch Llama Tools Launch your MCP Top Web Development Companies in the US - OnToplist.com Designer Listings Listed on SeeWhatNewAI Featured on SubmitMySaas Featured on AI Agents Directory Product Wing SaaS Wheel Featured on Stremit Featured on Thank John We Are Founders SubmitMySaas ShinyLaunch SaaS Tools Dir Featured on SaasHunt Product List Dir Featured on ShowMeBestAI Listed on Best-AI.org Featured on SaaSCity Listed on LaunchPact CodexFuse Solution on goodSaaS Featured on IndieLaunch Featured on BestAIApps AI X Collection Featured on SemiLaunch Listed on AlterBase We Like Tools codexfuse.dev LaunchClash Featured on Next Launch