<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openssl.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fabianocp</id>
	<title>OpenSSLWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openssl.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fabianocp"/>
	<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php/Special:Contributions/Fabianocp"/>
	<updated>2026-04-11T13:30:57Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.13</generator>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Base64&amp;diff=2600</id>
		<title>Base64</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Base64&amp;diff=2600"/>
		<updated>2017-06-27T15:58:55Z</updated>

		<summary type="html">&lt;p&gt;Fabianocp: /* EVP API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Encode binary information 8 bits into ASCII.&lt;br /&gt;
&lt;br /&gt;
This is PEM base encode, it exists other base64 encoding scheme like this used by crypt.&lt;br /&gt;
&lt;br /&gt;
== Algorithm ==&lt;br /&gt;
&lt;br /&gt;
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 :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ &lt;br /&gt;
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||&lt;br /&gt;
0000000000111111111122222222223333333333444444444455555555556666&lt;br /&gt;
0123456789012345678901234567890123456789012345678901234567890123&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[what makes 26 * 2 + 10 + 2 = 64 values]&lt;br /&gt;
&lt;br /&gt;
Since it encodes 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.&lt;br /&gt;
&lt;br /&gt;
== Openssl command ==&lt;br /&gt;
&lt;br /&gt;
base64 or -enc base64 can be used to decode lines see [[Command_Line_Utilities]]&lt;br /&gt;
&lt;br /&gt;
== EVP API ==&lt;br /&gt;
&lt;br /&gt;
crypto/evp/encode.c&lt;br /&gt;
crypto/evp/bio_b64.C&lt;br /&gt;
&lt;br /&gt;
If you need to encode a block of data, use the '''&amp;lt;tt&amp;gt;EVP_EncodeBlock&amp;lt;/tt&amp;gt;''' function, example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unsigned char sourceData[16] = {0x30,0x82,0x07,0x39,0x30,0x82,0x05,0x21,0xA0,0x03,0x02,0x01,0x02,0x02,0x04,0x00};&lt;br /&gt;
char encodedData[100];&lt;br /&gt;
EVP_EncodeBlock((unsigned char *)encodedData, sourceData, 16);&lt;br /&gt;
printf(encodedData);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== WARNINGS ===&lt;br /&gt;
&lt;br /&gt;
=== other unsupported base64 scheme ===&lt;br /&gt;
&lt;br /&gt;
Warning crypt() password encryption function uses another base64 scheme which is not the openssl base64 one. :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&lt;br /&gt;
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||&lt;br /&gt;
0000000000111111111122222222223333333333444444444455555555556666&lt;br /&gt;
0123456789012345678901234567890123456789012345678901234567890123&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== base64 uses PEM 80 characters per line ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
With C code it is possible to ask to disregard lines breaks : BIO_set_flags(d,BIO_FLAGS_BASE64_NO_NL);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Encoding]]&lt;/div&gt;</summary>
		<author><name>Fabianocp</name></author>
	</entry>
</feed>