Decoding base64 “atob” in Javascript NodeJS

atob() is a javascript function that decodes base64 encoded text. btoa() is the encoding function. We can use NodeJS to dedcode atob() functions. For instance, we can lanch nodejs woth

nodejs

and decode the sting SGVsbG8gV29ybGQgIQ==

console.log(atob("SGVsbG8gV29ybGQgIQ=="));

If we wanted to break that down into a couple variables we can do something like the following.

> var b64 = atob("SGVsbG8gV29ybGQgIQ==")
> console.log(b64");

You can also create a javascript file and then run the file with nodejs.

var b64 = atob(atob("U0dWc2JHOGdWMjl5YkdRZ0lRPT0="))

console.log(b64);

We can then run the file with

nodejs ./file.js

In the file the string “Hello World !” is double encoded so we process it twice with the “atob(atob(base64);”

There is more info available at the following links

https://www.npmjs.com/package/atob
https://developer.mozilla.org/en-US/docs/Web/API/atob

Check out the following article if you want to use Python to decode base64.