CCalclabhub

Text & Writing

Padding

A final group of one byte takes two equals signs, a group of two takes one, and a full group takes none.

The Formula

padding = (3 - (bytes mod 3)) mod 3 equals signs

A final group of one byte takes two equals signs, a group of two takes one, and a full group takes none.

SymbolMeaning
nInput bytes
pPadding

What Each Symbol Means

nbytes

Input bytes

The size of the data in bytes.

pcharacters

Padding

How many equals signs the output ends with.

See It Worked With Real Numbers

A formula on its own does not tell you which number goes where. The how to encode text to base64 page applies this equation to a concrete case, shows every intermediate step, and names the mistakes that produce a wrong answer even when the algebra is right.

Where This Formula Appears

This equation is the working core of How To Encode Text To Base64, filed under Everyday Life. Every number the guide produces comes from substituting into this one line.