base64 encode/decode in Node.js
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
|var url = "http://cdn1.giltcdn.com/images/share/uploads/0000/0001/7250/172502872/420x560.jpg";|
|var encoded = new Buffer(url).toString('base64');|
|var decoded = new Buffer(encoded, 'base64').toString('ascii')|
May 2, 2019
The usage of
new Buffer() is deprecated. You could use instead
Jun 30, 2019
I know its probably a typo, but I want to clarify that it should be
Buffer.from(url).toString('base64') without the
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@madanmishra i think you forgot to copy to line 2.
The line 3 is using the variable
encodedfrom the line 2. Then the line 3 can't work without the line 2.
Hope it helps.