alcuadrado/alcuadrado.github.com — pull request #2 by mathiasbynens (2012-08-12 09:29:00+00:00)
Title: Correction: Node.js doesn’t support `btoa()`

Only browsers have to implement it, as it’s part of the HTML spec, not ECMAScript: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#atob.

Instead, you can use `new Buffer('Hello World').toString('base64')` — which is different than `btoa` in that it encodes the string as UTF-8 first, while `btoa` only accepts extended ASCII characters. For example, `btoa('foo ♥ bar')` throws an error, but `new Buffer('foo ♥ bar').toString('base64')` works just fine. See http://mothereff.in/base64 for some more info and https://github.com/mathiasbynens/mothereff.in/blob/master/base64/eff.js for example code.