base64

A C++ module for node-js that does base64 encoding and decoding.

MIT 9 个版本
安装
npm install base64
yarn add base64
pnpm add base64
bun add base64
README

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 (peter@catonmat.net). His blog is at http://www.catonmat.net -- 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.

encode

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');

sys.print(base64_encode(buf));

/* Output: aGVsbG8gd29ybGQ= */

decode

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

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

sys.print(base64_decode('aGVsbG8gd29ybGQ='));

/* Output: hello world */

SGF2ZSBmdW4hCg==

Sincerely, Peteris Krumins http://www.catonmat.net

版本列表
2.1.0 2013-06-11
2.0.7 2012-03-03
2.0.6 2012-02-01
2.0.4 2012-01-29
2.0.3 2011-03-18
2.0.2 2011-03-17
2.0.1 2011-02-01
1.0.1 2011-01-18
1.0.0 2011-01-18