({{, (RefLink[BaseEncode, paclet:ref/BaseEncode])[ba] 
encodes the byte array ba as a Base64 string.}})

OpenersNotesSection(Spacer1)Details

In (RefLink[BaseEncode, paclet:ref/BaseEncode])[ba], ba should be a (RefLink[ByteArray, paclet:ref/ByteArray]) object.

(RefLink[BaseEncode, paclet:ref/BaseEncode]) uses the default encoding scheme described in the internet standard recommendation RFC 4648.

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Encode a byte array:

BaseEncode[ByteArray[]]

OpenersExampleSection1(Spacer1)Scope  (1)

Encode the bytes 1 through 12:

bytes=ByteArray[Range[12]]

BaseEncode[%]

The bytes can be recovered using (RefLink[BaseDecode, paclet:ref/BaseDecode]):

BaseDecode[%]//Normal

OpenersExampleSection3(Spacer1)Properties & Relations  (6)

The string returned by (RefLink[BaseEncode, paclet:ref/BaseEncode])[ba] has length divisible by 4:

BaseEncode[ByteArray[{1,2,3}]]

Padding will be added, if necessary:

BaseEncode[ByteArray[{1}]]

BaseEncode[ByteArray[{1,2}]]

(RefLink[BaseEncode, paclet:ref/BaseEncode]) is the inverse of (RefLink[BaseDecode, paclet:ref/BaseDecode]):

BaseDecode["ABCD"]

BaseEncode[%]

(RefLink[BaseEncode, paclet:ref/BaseEncode]) encodes binary data as a Base64 string:

BaseEncode[ByteArray[{1,2,3,4,5}]]

The export format "Base64" encodes the string representation of an expression converted to bytes:

ExportString[{1,2,3,4,5},"Base64"]

Achieve the same result with (RefLink[BaseEncode, paclet:ref/BaseEncode]), (RefLink[ToString, paclet:ref/ToString]) and (RefLink[ByteArrayToString, paclet:ref/ByteArrayToString]):

BaseEncode[StringToByteArray[ToString[{1,2,3,4,5}],"ISO8859-1"]]

(RefLink[BaseEncode, paclet:ref/BaseEncode]) converts a sequence of bytes to a sequence of characters:

BaseEncode[ByteArray[{0}]]

BaseEncode[ByteArray[{0,0,0,100,0,0}]]

(RefLink[IntegerString, paclet:ref/IntegerString]) converts integers to a base-64 representation using the alphabet of (StringTypeLink[Base64, paclet:ref/format/Base64]):

IntegerString[0,"Base64"]

IntegerString[100*(256^3),"Base64"]

(RefLink[BaseEncode, paclet:ref/BaseEncode]) converts the "ByteArray" format of (RefLink[Hash, paclet:ref/Hash]) to its "Base64Encoding" format:

BaseEncode@Hash["My String","CRC32","ByteArray"]==Hash["My String","CRC32","Base64Encoding"]

(RefLink[ByteArray, paclet:ref/ByteArray]) uses Base64 encoding of its data in (RefLink[InputForm, paclet:ref/InputForm]):

ByteArray[{1,2,3}]//InputForm

BaseEncode[ByteArray[{1,2,3}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BaseDecode, paclet:ref/BaseDecode])  ▪  (RefLink[ExportString, paclet:ref/ExportString])  ▪  (RefLink[StringToByteArray, paclet:ref/StringToByteArray])  ▪  (RefLink[ByteArrayToString, paclet:ref/ByteArrayToString])  ▪  (RefLink[Hash, paclet:ref/Hash])  ▪  (RefLink[ByteArray, paclet:ref/ByteArray])  ▪  (RefLink[IntegerString, paclet:ref/IntegerString])}, {Related Formats:  (RefLink[Base64, paclet:ref/format/Base64])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Binary Data, paclet:guide/BinaryData])}, {▪(RefLinkPlain[Cryptographic Number Theory, paclet:guide/CryptographicNumberTheory])}, {▪(RefLinkPlain[Importing and Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Cryptography, paclet:guide/Cryptography])}, {▪(RefLinkPlain[Network Programming, paclet:guide/NetworkProgramming])}})}})