Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A base64 encoding and decoding C++ module for node.js that actually works! (node now has it's own base64 encoding, see docs!)
C C++ Python JavaScript Shell Perl
branch: master

Merge pull request #18 from kuebk/node10

Node v0.10.x support
latest commit b2830cde7f
@pkrumins authored
Failed to load latest commit information.
test dirname for the expresso test
.npmignore Node v0.10.x support Node v0.10.x support
binding.gyp Node v0.10.x support
package.json Node v0.10.x support
readme.txt this module no longer necessary


Update: this module may no longer be necessary as nodejs includes its own
base64 encoding/decoding functions.

This is a node.js C++ module that encodes and decodes to/from base64. Oh, and
compared to all other modules, it actually works.

It was written by Peteris Krumins (
His blog is at  --  good coders code, great reuse.


To build the module run:

    node-waf configure build

This will produce `base64.node` binary module. To use it, make sure the
module's directory is in NODE_PATH.

The module exports two functions `encode` and `decode`.


Encodes a buffer to base64, returns encoded ascii string. Unlike all other
base64, it actually works well with binary data. If you're wondering why it
takes a buffer as argument, it's because there is no way to pass binary
strings to C++ code in a sane way.

Here is a basic example:

    var sys = require('sys');
    var base64_encode = require('base64').encode;
    var Buffer = require('buffer').Buffer;
    var buf = new Buffer('hello world');


    /* Output: aGVsbG8gd29ybGQ= */


Decodes a buffer containing base64 string, or just a base64 string to original

    var sys = require('sys');
    var base64_decode = require('base64').decode;


    /* Output: hello world */



Peteris Krumins

Something went wrong with that request. Please try again.