What fills the last row when the data runs out?
02Filling bits and equals-sign ending marks have different jobs. Neither adds an extra data byte.
We still start with whole input bytes, never a fraction of a byte.
Original data pieces
Each tiny place is a bit: filled = on, empty = off.
What happens if you change this?
Make one change, then watch again. Restart restores the original example.
TQ== represents the original one byte.
Key idea: Zero filling bits complete a symbol. Equals signs describe the end; they are not extra bytes.
Terms
- Base encoding
- A reversible way to represent bytes with a selected alphabet of text symbols. It is not encryption.
- Alphabet
- The agreed dictionary of symbols. Base64 and Base64url use different alphabets.
- Byte / bit
- One byte contains eight on-or-off values called bits.
- Padding / pad bits
- Equals-sign ending marks / zero filling bits inside the final data symbol. They are different things.
- Profile
- The containing format’s explicit extra rules, such as whether padding is omitted.
- Canonical form
- A specified consistent spelling. Being decodable does not guarantee that spelling.
Rules & examples
Zero filling bits complete a symbol. Equals signs describe the end; they are not extra bytes.
- Encoders must include padding unless the referring specification explicitly says otherwise.
- Unused pad bits must be zero for canonical encoding.
- A decoder may reject nonzero pad bits according to its profile.
Examples are illustrative. Consult the linked RFC and its errata for implementation details.
RFC 4648 §§3.2,3.5,4. Encoders MUST use zero pad bits and MUST include padding unless the referring specification explicitly says otherwise. This chosen decoder permits nonzero pad bits to demonstrate the difference: decoders MAY reject them. 4 filling bits; 2 equals signs under this selected profile. Output Zg==.
Sources
New to this? Start hereA quick picture + helpful background
First, agree how to read the message.
An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.
Start with this guide; no earlier guide is needed for the overview.
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.