Buffers can be used for taking a string or piece of data and doing base64 encoding of the result. For example:
You can install Buffer via npm like :- npm i buffer --save
you can use this in your js
file like this :-
var buffer = require('buffer/').Buffer;
->> console.log(buffer.from("Hello Vishal Thakur").toString('base64'));
SGVsbG8gVmlzaGFsIFRoYWt1cg== // Result
->> console.log(buffer.from("SGVsbG8gVmlzaGFsIFRoYWt1cg==", 'base64').toString('ascii'))
Hello Vishal Thakur // Result