I am Hack Sparrow
Captain of the Internets.

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 ...

Using Node.js to download files

There are three approaches to writing a file downloader app using Node - i. HTTP.get, ii. curl, iii. wget. I have created functions for all of them. To get the examples working makes sure you have the dependencies and app variables intact. Read the comments thoroughly, you will not only learn how to download files, but will also learn more about Node's child_process, File System, Buffers, and Streams. Let's start with HTTP.get. ...