How to create Base64 encode/decode Strings in Node.js?

Today, I gonna show you guys how we can encode and decode (Base64) the string in Node.js project. First, you need to create the Node server and copy the below codes to server.js for the testing.

Encoding
const encodedString = Buffer.from(“Hello Node”).toString(‘base64’);

Decoding
const decodedString = Buffer.from(“SGVsbG8gTm9kZQ==”, ‘base64’).toString(‘ascii’);

That’s it. I hope this will help. πŸ™‚
Photo: https://www.brandeps.com

Leave a Reply

Your email address will not be published. Required fields are marked *