1 2 3 4 5 6 7
String.prototype.toBase64 = function() { return Buffer(this.toString()).toString('base64'); }; String.prototype.fromBase64 = function() { return Buffer(this.toString(), 'base64').toString('utf8'); };