Base64 Valid Character Set

I found this on a forum post, and just wanted to verify that this information is correct:

for base64 the valid charset is:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx yz0123456789+/
the = is used as filler for the last bytes, as the length must be mulitple
of 3


The charset looks reasonable, but must the length be a multiple of 3? (Seems like a multiple of 4 would make more sense.)

Comments very much appreciated!

3 thoughts on “Base64 Valid Character Set

  1. I was searching about some features of the base64 encoding when I looked your page, I think that you already know about the “=” character on the encoding, well, I want to publish here, the “=” character “is used to signify a special processing functions”, you can look the definition in the RFC:
    And yes, the length of the text must be 3, because 24 bits (3 bytes) are treated as 4 concatened 6-bit groups, so a padding is used in a text where its length is not multiple of 3.
    b64(‘a’) = “YQ==”
    b64(“ab”) = “YWI=”
    b64(“abc”) = “YWJj”
    b64(“abcd”) = “YWJjZA==”

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s