Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Base64
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Output padding=== Because Base64 is a six-bit encoding, and because the decoded values are divided into 8-bit octets, every four characters of Base64-encoded text (4 sextets = {{times|4|6}} = 24 bits) represents three octets of unencoded text or data (3 octets = {{times|3|8}} = 24 bits). This means that when the length of the unencoded input is not a multiple of three, the encoded output must have padding added so that its length is a multiple of four. The padding character is <code>=</code>, which indicates that no further bits are needed to fully encode the input. (This is different from <code>A</code>, which means that the remaining bits are all zeros.) The example below illustrates how truncating the input of the above quote changes the output padding: <!-- This is the encoding of **THE WHOLE** of the above passage and the ending fits in with both the above encoding and the first line of the following example, verified using http://www.motobit.com/util/base64-decoder-encoder.asp In the previous version, the example started with a space, which was not visible and thus quite misleading. --> {|class="wikitable" ! scope="col" colspan=2 | Input ! scope="col" colspan=2 | Output ! scope="col" rowspan=2 | Padding |- ! scope="col" | Text ! scope="col" | Length ! scope="col" | Text ! scope="col" | Length |- | ''light {{bg|lightgrey|wor}}{{bg|#cef2e0|k.}}'' || 11 | {{mono|1=bGlnaHQg{{bg|lightgrey|d29y}}{{bg|#cef2e0|2=ay4=}}}} || 16 | 1 |- | ''light {{bg|lightgrey|wor}}{{bg|#cef2e0|k}}'' || 10 | {{mono|1=bGlnaHQg{{bg|lightgrey|d29y}}{{bg|#cef2e0|2=aw==}}}} || 16 | 2 |- | ''light {{bg|lightgrey|wor}}'' || 9 | {{mono|1=bGlnaHQg{{bg|lightgrey|d29y}}}} || 12 | 0 |- | ''light {{bg|lightgrey|wo}}'' || 8 | {{mono|1=bGlnaHQg{{bg|lightgrey|2=d28=}}}} || 12 | 1 |- | ''light {{bg|lightgrey|w}}'' || 7 | {{mono|1=bGlnaHQg{{bg|lightgrey|2=dw==}}}} || 12 | 2 |} The padding character is not essential for decoding, since the number of missing bytes can be inferred from the length of the encoded text. In some implementations, the padding character is mandatory, while for others it is not used. An exception in which padding characters are required is when multiple Base64 encoded files have been concatenated.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)