Zum Inhalt springen
uencoder

Base64 Alphabet Referenz

Der abschließen Base64 alphabet, padding Regeln, und URL-sicher variant verwendet durch RFC 4648.

Standard Alphabet

The standard Base64 alphabet defined by RFC 4648 consists of 64 printable ASCII characters. It maps each 6-bit group to a single character, enabling binary data to be represented as text. The alphabet is ordered so that the numeric value of a byte corresponds directly to its index in the table. This ordering makes encoding and decoding a simple table lookup with no arithmetic required.

A-Z
Values 0-25, uppercase Latin letters
A=0, B=1, ..., Z=25
a-z
Values 26-51, lowercase Latin letters
a=26, b=27, ..., z=51
0-9
Values 52-61, decimal digits
0=52, 1=53, ..., 9=61
+
Value 62, plus sign
+ maps to 62
/
Value 63, forward slash
/ maps to 63
=
Padding character, not a data symbol
QQ== pads 1 byte

URL-safe Variant

Because the plus and slash characters are reserved in URLs, RFC 4648 defines a URL-safe alphabet that substitutes hyphen for plus and underscore for slash. This variant eliminates the need to percent-encode Base64 values placed in query strings or path segments. Padding with the equals sign is typically omitted in token contexts such as JWTs. Decoders must know which variant was used to avoid silent corruption.

-
Replaces plus (value 62) in URL-safe Base64
ab+cd becomes ab-cd
_
Replaces slash (value 63) in URL-safe Base64
ab/cd becomes ab_cd
no padding
Trailing equals often stripped for compact tokens
QQ== becomes QQ

Padding Rules

Base64 encodes 3 bytes into 4 characters, so input lengths not divisible by 3 require padding. One extra byte produces two Base64 characters followed by two equals signs, while two extra bytes produce three characters followed by one equals sign. The padding lets decoders recover the exact original length. Strict decoders reject missing or incorrect padding, while lenient ones infer it from the string length.

Verwandte Tools

参考链接