.TH base64 3erl "stdlib 5.2.2" "Ericsson AB" "Erlang Module Definition" .SH NAME base64 \- Provides base64 encode and decode, see RFC 2045. .SH DESCRIPTION .LP Provides base64 encode and decode, see RFC 2045\&. .SH DATA TYPES .nf \fBbase64_alphabet()\fR\& = .br 65\&.\&.90 | 97\&.\&.122 | 48\&.\&.57 | 43 | 47 | 45 | 95 | 61 .br .fi .RS .LP Base 64 Encoding alphabet, see RFC 4648\&. .RE .nf \fBbase64_mode()\fR\& = standard | urlsafe .br .fi .RS .LP Selector for the Base 64 Encoding alphabet used for encoding and decoding\&. See RFC 4648 Sections 4 and 5\&. .RE .nf \fBoptions()\fR\& = #{padding => boolean(), mode => base64_mode()} .br .fi .RS .LP Customises the behaviour of the encode and decode functions\&. Default value if omitted entirely or partially is \fI#{mode => standard, padding => true}\fR\&\&. .RE .nf \fBbase64_string()\fR\& = [base64_alphabet()] .br .fi .RS .LP Base 64 encoded string\&. .RE .nf \fBbase64_binary()\fR\& = binary() .br .fi .RS .LP Base 64 encoded binary\&. .RE .nf \fBbyte_string()\fR\& = [byte()] .br .fi .RS .LP Arbitrary sequences of octets\&. .RE .SH EXPORTS .LP .nf .B decode(Base64) -> Data .br .fi .br .nf .B decode_to_string(Base64) -> DataString .br .fi .br .nf .B mime_decode(Base64) -> Data .br .fi .br .nf .B mime_decode_to_string(Base64) -> DataString .br .fi .br .RS .LP Types: .RS 3 Base64 = base64_string() | base64_binary() .br Data = binary() .br DataString = byte_string() .br .RE .RE .RS .LP Decodes a base64 string encoded using the standard alphabet according to RFC 4648 Section 4 to plain ASCII\&. .LP \fImime_decode/1\fR\& and \fImime_decode_to_string/1\fR\& strip away illegal characters, while \fIdecode/1\fR\& and \fIdecode_to_string/1\fR\& only strip away whitespace characters\&. .LP Checks the correct number of \fI=\fR\& padding characters at the end of the encoded string\&. .RE .LP .nf .B decode(Base64, Options) -> Data .br .fi .br .nf .B decode_to_string(Base64, Options) -> DataString .br .fi .br .nf .B mime_decode(Base64, Options) -> Data .br .fi .br .nf .B mime_decode_to_string(Base64, Options) -> DataString .br .fi .br .RS .LP Types: .RS 3 Base64 = base64_string() | base64_binary() .br Options = options() .br Data = binary() .br DataString = byte_string() .br .RE .RE .RS .LP Decodes a base64 string encoded using the alphabet indicated by the \fImode\fR\& option to plain ASCII\&. .LP \fImime_decode/2\fR\& and \fImime_decode_to_string/2\fR\& strip away illegal characters, while \fIdecode/2\fR\& and \fIdecode_to_string/2\fR\& only strip away whitespace characters\&. .LP The \fImode\fR\& option can be one of the following: .RS 2 .TP 2 .B \fIstandard\fR\&: Default\&. Decode the given string using the standard base64 alphabet according to RFC 4648 Section 4, that is \fI"+"\fR\& and \fI"/"\fR\& are representing bytes \fI62\fR\& and \fI63\fR\& respectively, while \fI"-"\fR\& and \fI"_"\fR\& are illegal characters\&. .TP 2 .B \fIurlsafe\fR\&: Decode the given string using the alternative "URL and Filename safe" base64 alphabet according to RFC 4648 Section 5, that is \fI"-"\fR\& and \fI"_"\fR\& are representing bytes \fI62\fR\& and \fI63\fR\& respectively, while \fI"+"\fR\& and \fI"/"\fR\& are illegal characters\&. .RE .LP The \fIpadding\fR\& option can be one of the following: .RS 2 .TP 2 .B \fItrue\fR\&: Default\&. Checks the correct number of \fI=\fR\& padding characters at the end of the encoded string\&. .TP 2 .B \fIfalse\fR\&: Accepts an encoded string with missing \fI=\fR\& padding characters at the end\&. .RE .RE .LP .nf .B encode(Data) -> Base64 .br .fi .br .nf .B encode_to_string(Data) -> Base64String .br .fi .br .RS .LP Types: .RS 3 Data = byte_string() | binary() .br Base64 = base64_binary() .br Base64String = base64_string() .br .RE .RE .RS .LP Encodes a plain ASCII string into base64 using the standard alphabet according to RFC 4648 Section 4\&. The result is 33% larger than the data\&. .LP Always appends correct number of \fI=\fR\& padding characters to the encoded string\&. .RE .LP .nf .B encode(Data, Options) -> Base64 .br .fi .br .nf .B encode_to_string(Data, Options) -> Base64String .br .fi .br .RS .LP Types: .RS 3 Data = byte_string() | binary() .br Options = options() .br Base64 = base64_binary() .br Base64String = base64_string() .br .RE .RE .RS .LP Encodes a plain ASCII string into base64 using the alphabet indicated by the \fImode\fR\& option\&. The result is 33% larger than the data\&. .LP The \fImode\fR\& option can be one of the following: .RS 2 .TP 2 .B \fIstandard\fR\&: Default\&. Encode the given string using the standard base64 alphabet according to RFC 4648 Section 4\&. .TP 2 .B \fIurlsafe\fR\&: Encode the given string using the alternative "URL and Filename safe" base64 alphabet according to RFC 4648 Section 5\&. .RE .LP The \fIpadding\fR\& option can be one of the following: .RS 2 .TP 2 .B \fItrue\fR\&: Default\&. Appends correct number of \fI=\fR\& padding characters to the encoded string\&. .TP 2 .B \fIfalse\fR\&: Skips appending \fI=\fR\& padding characters to the encoded string\&. .RE .RE