AtoB and BtoA in Node

Posted on October 13, 2021

atob in Node.js:

const atob = (base64) => {
  return Buffer.from(base64, 'base64').toString('binary')
}

btoa in Node.js:

const btoa = (text) => {
    return Buffer.from(text, 'binary').toString('base64');
}

Source here.