Difference between revisions of "Base64"

From OpenSSLWiki
Jump to navigationJump to search
(Created page with "Encode binary information 8 bits into ASCII. 3 x 8 bits binary are concatenated to form a 24bits word that is split in 4 x 6bits each being translating into an ascii value using …")
 
Line 1: Line 1:
 
Encode binary information 8 bits into ASCII.
 
Encode binary information 8 bits into ASCII.
 
3 x 8 bits binary are concatenated to form a 24bits word that is split in 4 x 6bits each being translating into an ascii value using a character ordered in following list :
 
3 x 8 bits binary are concatenated to form a 24bits word that is split in 4 x 6bits each being translating into an ascii value using a character ordered in following list :
A..Za..z0..9+/ [what makes 26 * 2 + 10 + 2 = 64 values]  
+
 
 +
<pre>
 +
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/  
 +
0000000000111111111122222222223333333333444444444455555555556666
 +
0123456789012345678901234567890123456789012345678901234567890123
 +
</pre>
 +
 
 +
[what makes 26 * 2 + 10 + 2 = 64 values]
 +
 
 +
 
 +
 
 +
 
 
Since it encode by group of 3 bytes, when last group of 3 bytes miss one byte then = is used, when it miss 2 bytes then == is used for padding.
 
Since it encode by group of 3 bytes, when last group of 3 bytes miss one byte then = is used, when it miss 2 bytes then == is used for padding.
  

Revision as of 19:32, 24 March 2013

Encode binary information 8 bits into ASCII. 3 x 8 bits binary are concatenated to form a 24bits word that is split in 4 x 6bits each being translating into an ascii value using a character ordered in following list :

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ 
0000000000111111111122222222223333333333444444444455555555556666
0123456789012345678901234567890123456789012345678901234567890123

[what makes 26 * 2 + 10 + 2 = 64 values]



Since it encode by group of 3 bytes, when last group of 3 bytes miss one byte then = is used, when it miss 2 bytes then == is used for padding.

Base64 itself does not impose a line split, but openssl uses it in PEM context hence enforce that base64 content is splitted by lines with a maximum of 80 characters.