node alternative to btoa

The Buffer class in Node.js can be used as an alternative to the btoa function in the browser. The following steps illustrate how to achieve this:

  1. Create a buffer from the input string using Buffer.from(inputString).
  2. Encode the buffer using the toString method and specifying the encoding type as 'base64'.
  3. The encoded string will be the equivalent of the result obtained from btoa in the browser environment.