GithubHelp home page GithubHelp logo

ncb000gt / node-base64 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pkrumins/node-base64

1.0 3.0 1.0 200 KB

A base64 encoding and decoding C++ module for node.js that actually works!

Perl 1.06% Shell 1.89% JavaScript 7.76% C++ 21.94% C 67.36%

node-base64's Introduction

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 ([email protected]).
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

node-base64's People

Contributors

ncb000gt avatar pkrumins avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.