Search…
Base64 Module
Simple, fast base64 encoding/decoding service. Import
1
import base64 from 'base64';
Copied!

Methods

encode(value)

Encode a string.
Arguments
  • value (String) a string to base64 encode
Returns
  • value (String) a base64 encoded string

decode(value, asBuffer)

Decode a string into a string or buffer.
Arguments
  • value (String) a base64 string to decode
  • asBuffer (Boolean=false) If true, returns a buffer instead of a string.
Returns
  • value (String|Buffer) a decoded string/buffer

Examples

Encode Example
1
import base64 from 'base64'
2
return base64.encode('Hold Me, Thrill Me, Encode Me')
Copied!
Encode Response
1
{
2
"object": "result",
3
"data": "SG9sZCBNZSwgVGhyaWxsIE1lLCBFbmNvZGUgTWU="
4
}
Copied!
Decode Example
1
import base64 from 'base64'
2
return base64.decode('SG9sZCBNZSwgVGhyaWxsIE1lLCBFbmNvZGUgTWU=')
Copied!
Decode Response
1
{
2
"object": "result",
3
"data": "Hold Me, Thrill Me, Encode Me"
4
}
Copied!
Last modified 2mo ago