Module basic module

Module base64

base64 encoding and decoding module

Reference method:

1 2
var encoding = require('encoding'); var base64 = encoding.base64;

or

1
var base64 = require('base64');

Static function

encode

Encode data in base64

1 2
static String base64.encode(Buffer data, Boolean url = false);

Call parameters:

  • data : Buffer , the data to be encoded
  • url : Boolean, specify whether to use url safe character encoding

Return result:

  • String , returns the encoded string

decode

Decode a string into binary data in base64 mode

1
static Buffer base64.decode(String data);

Call parameters:

  • data : String, the string to be decoded

Return result:

  • Buffer , returns the decoded binary data