base64 encode/decode for node and browser
// Simple Base64 encode/decode that works in node and the browser.
var base64 = {
encode: function (text) {
if (typeof btoa === 'function')
return btoa(text)
else
return new Buffer(text).toString('base64')
},
decode: function (text) {
if (typeof atob === 'function')
return atob(text)
else
return new Buffer(text, 'base64').toString('utf8')
}
}