Encoding a string to base64
const buff = Buffer.from("hi readers", "utf8");
const base64 = buff.toString("base64");
console.log(base64); // aGkgcmVhZGVycw==
Decoding a base64 to a string
Similarly, we can decode a base64 encoding to a string like this.
const buff = Buffer.from("aGkgcmVhZGVycw==", "base64");
const str = buff.toString("utf8");
console.log(str); // hi readers