English
HTTP Basic Authentication Header: Base64 Format, HTTPS & cURL
HTTP Basic Authentication is a simple way for an HTTP client to send a username and password with a request. The credentials are combined as username:password, encoded with Base64, and placed after the Basic scheme in the Authorization request header.
The format is easy to generate, but it is often misunderstood. Base64 is an encoding, not encryption. Anyone who can read the header can recover the credentials, so Basic Authentication must be protected by HTTPS and handled like a password.
How the Authorization header is formed
The Basic scheme starts with the username, a colon, and the password:
text
username:password1
The complete byte sequence is then Base64-encoded. The result is sent in this form:
http
Authorization: Basic <base64-credentials>1
For the sample username demo and password example, the combined text is demo:example. Its Base64 representation is ZGVtbzpleGFtcGxl, so the header becomes:
http
Authorization: Basic ZGVtbzpleGFtcGxl1
Base64 changes the representation of the data; it does not make the credentials secret. Decoding the sample value immediately reveals demo:example.
Generate a Basic Authentication header
To build a header for an API request:
- Confirm that the API actually uses HTTP Basic Authentication. Do not substitute it for a bearer token, API key or another authentication scheme.
- Enter the username and password in a trusted client or local tool.
- Combine the values as
username:passwordand Base64-encode the resulting bytes. - Prefix the encoded value with
Authorization: Basic. - Send the request only over HTTPS, and avoid writing the raw password or header into logs, tickets or shared chat.
The DigDevBox Basic Auth Generator creates the complete Authorization header from a username and password. It also includes a decoder for an existing Basic header or Base64 token, so you can inspect the username and password represented by a value you already have. Both operations are performed by the browser page; the tool does not submit credentials to an account service.
Treat the generated header as a credential. Anyone who obtains it can decode the username and password.
Decode an existing Basic Auth header
A Basic Authorization value can be decoded because Base64 is reversible. The decoder accepts either a complete header such as Authorization: Basic ... or the Base64 token by itself.
After decoding, the first colon separates the username from the password. This matters because a password may itself contain colons. For example, the decoded text svc:pass:word represents username svc and password pass:word.
The HTTP Basic scheme does not allow a colon in the username: the first colon is the delimiter. If a username contains a colon, the receiver cannot distinguish it from the separator. Choose a different username or use the authentication mechanism specified by the service.
Only decode credentials you are authorized to inspect. Avoid pasting a production header into a shared workstation, screen recording, support ticket or public website. Clear the input when finished and rotate the credential if it has been exposed.
Send credentials with cURL
cURL can construct the Basic Authorization header when you use its --user option:
bash
curl --user "$BASIC_AUTH_USERNAME:$BASIC_AUTH_PASSWORD" https://api.example.com/1
Set the variables through your approved secret manager or shell environment before running the command. Avoid putting a real password directly in a command that may be saved in shell history or copied into a terminal transcript. Do not send Basic credentials to an HTTP URL; use HTTPS.
You can also supply an explicit header:
bash
curl --header "Authorization: Basic $BASIC_AUTH_TOKEN" https://api.example.com/1
In this example, BASIC_AUTH_TOKEN is the Base64-encoded username:password value. It is still a password-equivalent secret, not a safe-to-share string.
Security requirements and common mistakes
Base64 is not encryption. It provides no confidentiality, integrity or authentication by itself. Anyone who captures the header can decode it.
Use HTTPS for every request. TLS protects the request in transit between the client and the server. Do not rely on Base64 to hide credentials on an unencrypted connection.
Do not confuse Basic with Bearer. A Basic header contains an encoded username and password. A Bearer header carries a token. The prefixes are not interchangeable; follow the API's documentation.
Do not log the header. Reverse proxies, application logs, browser developer tools and debugging traces can accidentally retain Authorization values. Redact the header before sharing request logs.
Use a credential manager. Store passwords and tokens in an approved secret manager, not in source code, public repositories or long-lived shell scripts.
Respect the server's authentication policy. Some APIs disable Basic Authentication, require an application-specific password, or expect a different character encoding. A syntactically correct header does not guarantee that the server will accept it.
Troubleshooting a rejected header
If the server returns 401 Unauthorized, check the scheme first: the header must begin with Basic followed by the Base64 value. Then confirm the username and password, remove accidental spaces or line breaks, and make sure the request is reaching the intended host.
If you decode a header and the username looks correct but the password does not, check whether the original input included a trailing newline or unexpected whitespace. Encoding operates on bytes; a hidden character changes the result.
If the API expects a bearer token, an API key or mutual TLS, generating a Basic header will not solve the problem. Use the authentication method the service documents.
FAQ
Is HTTP Basic Authentication secure?
It can be used safely only when protected by HTTPS and handled carefully. The header is reversible Base64, not encryption. Without TLS, anyone who can capture the request can recover the credentials.
Can I decode a Basic Authentication header?
Yes. Base64 is reversible, so a complete Authorization: Basic header can be decoded to inspect the username and password. Only do this for credentials you are authorized to view, and avoid shared or untrusted devices.
Can a Basic Authentication password contain a colon?
Yes. The first colon in the decoded credential string separates the username from the password. Additional colons belong to the password. A colon cannot be used in the username under the Basic scheme.
Is a Basic header the same as a Bearer token?
No. Basic carries a Base64-encoded username and password. Bearer carries a token after the Bearer scheme. Use the scheme required by the API.
Does Base64 protect my password?
No. Base64 is a reversible text encoding. It does not encrypt or hash the password. HTTPS is required to protect credentials in transit.
More developer tools on DigDevBox
- Basic Auth Generator — create an HTTP Basic Authorization header or decode an existing header locally in the browser.
- Base64 String Converter — encode or decode Base64 text independently of HTTP authentication.
- API Debugger — inspect HTTP requests and responses when you are authorized to send the request.
A Basic header is a transport format for credentials, not a security boundary. Use the correct authentication scheme, protect the request with TLS, and keep the resulting header private.