Base64 Encoding / Decoding in Node.js
So how do you encode a string to base64 is Node.js? Is there something easy like base64_encode() of PHP's?
Node.js 'being' JavaScript, has a more logical approach to encoding strings, instead of having thousands of inconsistently defined global functions.
Here is how you encode normal text to base64 in Node.js:
[code]
var b = new Buffer('JavaScript');
var s = b.toString('base64');
// SmF2YVNjcmlwdA==
[/code]
And here is how you decode base64 encoded strings:
[code ...