Library

DFA · Regular

Base64 length and padding

Base64 text comes in blocks of four characters, and only the last block may end in padding: one = or two. a stands for any of the 64 characters. The states count the position within the current block and whether padding has begun, after which only = may follow.

p0p1p2p3pad1doneaaaa===
The machine as drawn — 6 states, 7 transitions.Every word up to length 8, one row per length in shortlex order, inked where it is accepted.

The author’s examples, run

ε → acceptaa== → acceptaaaaaa== → acceptaaaaaaa= → accepta → reject=a== → reject=aaaaa== → reject=aaaaaa= → reject