btoa for Node.JS (it's a one-liner)
Go to file
AJ ONeal 93ce8ddd9f handle actual binary, not just utf8 2012-09-19 14:22:55 -06:00
bin added cli tool 2012-06-26 13:28:01 -06:00
README.md handle actual binary, not just utf8 2012-09-19 14:22:55 -06:00
index.js Fix btoa to match browser implementations 2012-09-13 02:08:20 -03:00
package.json handle actual binary, not just utf8 2012-09-19 14:22:55 -06:00
test.js handle actual binary, not just utf8 2012-09-19 14:22:55 -06:00

README.md

btoa

Uses Buffer to emulate the exact functionality of the browser's btoa (except that it supports unicode and the browser may not).

It turns binary data to base64-encoded ascii.

(function () {
  "use strict";
  
  var btoa = require('btoa')
    , bin = "Hello, 世界"
    , b64 = btoa(bin)
    ;

  console.log(b64); // "SGVsbG8sIBZM"
}());

Note: Unicode may or may not be handled incorrectly.