Module ringo/base64
Base64 encoding and decoding for binary data and strings.
Example
>> const base64 = require('ringo/base64');
>> const enc = base64.encode('Hello World!', 'ISO-8859-15');
>> print(enc);
'SGVsbG8gV29ybGQh'
>> print(base64.decode(enc, 'ISO-8859-15'));
Hello World!
decode (str, encoding)
Decodes a Base64 encoded string to a string or byte array.
Parameters
String | str | the Base64 encoded string |
String | encoding | the encoding to use for the return value. Defaults to 'utf8'. Use 'raw' to get a ByteArray instead of a string. |
Returns
String|ByteArray | the decoded string or ByteArray |
encode (str, encoding)
Encode a string or binary to a Base64 encoded string
Parameters
String|Binary | str | a string or binary |
String | encoding | optional encoding to use if first argument is a string. Defaults to 'utf8'. |
Returns
String | the Base64 encoded string |