Last active
September 26, 2019 11:06
-
-
Save michelepatrassi/a5a35fd5a2429bfba39e35d984d1789b to your computer and use it in GitHub Desktop.
How to create base64 string and get it back in NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Buffer is a default Nodejs global object | |
const initialString = 'michelepatrassi'; | |
const token = Buffer.from(initialString).toString('base64'); | |
# want to get it back? | |
const welcomeBack = Buffer.from(token, 'base64').toString('ascii'); | |
if (initialString === welcomeBack) { | |
console.log('all good!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment