Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation.
In JavaScript there are two functions respectively for decoding and encoding base64 strings:
atob()
btoa()
In these APIs, for mnemonic purposes, the "b" can be considered to stand for "binary", and the "a" for "ASCII"
The atob() function decodes a string of data which has been encoded using base-64 encoding.
Conversely, the btoa() function creates a base-64 encoded ASCII string from a "string" of binary data.
Both atob() and btoa() work on strings
Syntax
var encodedData = scope.btoa(stringToEncode);
Parameters
stringToEncode
A string whose characters each represent a single byte of binary data to be encoded into ASCII.
Return value
A string containing the Base64 representation of stringToEncode.
Example
var encodedData = window.btoa('Hello, world'); // encode a string
var decodedData = window.atob(encodedData); // decode the string
In JavaScript there are two functions respectively for decoding and encoding base64 strings:
atob()
btoa()
In these APIs, for mnemonic purposes, the "b" can be considered to stand for "binary", and the "a" for "ASCII"
The atob() function decodes a string of data which has been encoded using base-64 encoding.
Conversely, the btoa() function creates a base-64 encoded ASCII string from a "string" of binary data.
Both atob() and btoa() work on strings
Syntax
var encodedData = scope.btoa(stringToEncode);
Parameters
stringToEncode
A string whose characters each represent a single byte of binary data to be encoded into ASCII.
Return value
A string containing the Base64 representation of stringToEncode.
Example
var encodedData = window.btoa('Hello, world'); // encode a string
var decodedData = window.atob(encodedData); // decode the string