Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beeven/node-b32
Implementation of RFC-3548 Base32 encoding/decoding for node using C. It's binary safe for using Buffer.
https://github.com/beeven/node-b32
Last synced: about 1 month ago
JSON representation
Implementation of RFC-3548 Base32 encoding/decoding for node using C. It's binary safe for using Buffer.
- Host: GitHub
- URL: https://github.com/beeven/node-b32
- Owner: beeven
- License: mit
- Created: 2014-10-05T13:06:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-16T14:00:56.000Z (almost 9 years ago)
- Last Synced: 2024-10-06T12:36:43.117Z (3 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
b32
========[![Build Status](https://travis-ci.org/beeven/node-b32.svg?branch=master)](https://travis-ci.org/beeven/node-b32)
[![Dependencies](https://david-dm.org/beeven/node-b32.svg)](https://david-dm.org/beeven/node-b32)Implementation of RFC-3548 Base32 encoding/decoding for node using C (suppose to be faster than pure javascript).
Features
----------
- Implemented in C
- Sync & Async methods support
- Options to add '=' paddings
- Promises chaining support (Thanks to q)Installation
-------------
```bash
npm install b32
```Test
-----------------
```bash
npm test
```Usage
-----------------
```javascript
var b32 = require("b32");
// Encode a string and use callback to pick up the result
b32.encode('foo',function(err,result){
console.log(result.toString());
});// Encode a buffer and use promises
b32.encode(new Buffer('foo\x00'),{padding:true})
.then(function(encoded_result){
console.log(encoded_result.toString());
return b32.decode(encoded_result);
})
.then(function(decoded_result){
console.log(decoded_result);
});// Decode a string in synchronize mode
var decoded = b32.decodeSync('MZXW6===');// Decode a buffer with async function
b32.decode(new Buffer('MZXW6')).
.then(function(result){
console.log(result);
});```
Functions
-------------
### encodeSync(Buffer[,options])
options:
- padding: Boolean (default: false) add '=' padding to the end
Returns:
Encoded base32 string in buffer### decodeSync(Buffer)
Returns:
Decoded binary buffer### encode(Buffer,[options],[callback])
options:
- same as sync function
callback: a function with signature function(err,result)
Returns:
A promise which will resolve with the result### decode(Buffer,[callback])
callback: a function with signature function(err,result)
Returns:
A promise which will resolve with the result