From user and password to Base64
02Basic serializes a user-id, a colon separator and a password, then encodes their bytes as Base64 text.
Base64 of the 19 bytes is QWxhZGRpbjpvcGVuIHNlc2FtZQ==. Prefix it with Basic in Authorization. Decoding recovers the password; this is not secrecy.
Source for this drawing: RFC 7617 · Read RFC section 2 ↗
New to this? Start hereA quick picture + helpful background
A message needs an address.
Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
- Octet
- An eight-bit byte.
- Base64
- A reversible representation of bytes using an ASCII alphabet.
- token68
- HTTP credential syntax carrying the one encoded Basic value.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
Construct user-pass as user-id + one colon + password, convert to octets, then use the standard Base64 alphabet from RFC 4648 §4.
- Construct user-pass as user-id + one colon + password, convert to octets, then use the standard Base64 alphabet from RFC 4648 §4.
- A user-id containing a colon is invalid. The first colon separates the user-id; any later colons are part of the password.
- The user-id and password MUST NOT contain control characters (CTL as referenced by §2). This is separate from choosing an encoding.
- The default character encoding is unspecified but must be compatible with US-ASCII. Base64 is reversible encoding; it provides no encryption or password hashing.
The worked example Aladdin / open sesame is from §2, with ASCII-compatible bytes 41 6C 61 64 64 69 6E 3A 6F 70 65 6E 20 73 65 73 61 6D 65. All credentials in this guide are public fictional examples. A colon in a password is permitted; a colon in the user-id cannot be disambiguated by escaping it in Basic.
Read the RFC section ↗