Comparing version 0.2.1 to 0.3.0
@@ -0,1 +1,5 @@ | ||
0.3.0 / 2014-02-24 | ||
------------------ | ||
* duck type input to `encode` and change output of `decode` to `Buffer`. | ||
0.2.1 / 2014-02-24 | ||
@@ -2,0 +6,0 @@ ------------------ |
var BigInteger = require('bigi'); | ||
var conv = require('binstring'); | ||
@@ -18,2 +19,4 @@ 'use strict' | ||
function encode (input) { | ||
var input = conv(input, {out: 'bytes'}); | ||
var bi = BigInteger.fromByteArrayUnsigned(input); | ||
@@ -73,3 +76,3 @@ var chars = []; | ||
return bytes; | ||
return new Buffer(bytes); | ||
} |
{ | ||
"name": "bs58", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Base58 check encoding", | ||
@@ -18,4 +18,5 @@ "keywords": [ | ||
"mocha": "1.*", | ||
"terst": "0.0.1", | ||
"convert-hex": "0.1.*" | ||
"terst": "0.0.2", | ||
"binstring": "~0.2.0", | ||
"mochify": "~0.4.2" | ||
}, | ||
@@ -28,4 +29,5 @@ "repository": { | ||
"dependencies": { | ||
"bigi": "0.2.0" | ||
"bigi": "0.2.0", | ||
"binstring": "~0.2.0" | ||
} | ||
} | ||
} |
@@ -14,12 +14,68 @@ bs58 | ||
### browser | ||
You can use this module in the browser. Install [Browserify](https://github.com/substack/node-browserify): | ||
npm install -g browserify | ||
then run: | ||
browserify < lib/bs58.js > lib/bs85.bundle.js | ||
Api | ||
--- | ||
### encode(arrayOfBytes) | ||
### encode(input) | ||
### decode(base58str) | ||
`input` can be either a hex string, an array of bytes, or a [Buffer](http://nodejs.org/api/buffer.html). It returns a `string`. | ||
**example (hex string)**: | ||
```js | ||
var base58 = require('bs58'); | ||
var unencodedData = "0x003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187"; //<-- notice the "0x" prefix? | ||
var out = base58.encode(unencodedData); | ||
console.log(out); // => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS" | ||
``` | ||
** example (byte array)**: | ||
```js | ||
var base58 = require('bs58'); | ||
var conv = require('binstring') | ||
var unencodedData = "003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187"; | ||
var out = base58.encode(conv(unencodedData: {in: 'hex', out: 'bytes'})); | ||
console.log(out); // => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS" | ||
``` | ||
** example (Buffer)**: | ||
```js | ||
var base58 = require('bs58'); | ||
var conv = require('binstring') | ||
var unencodedData = "003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187"; | ||
var out = base58.encode(conv(unencodedData: {in: 'hex', out: 'buffer'})); | ||
console.log(out); // => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS" | ||
``` | ||
### decode(input) | ||
`input` must be a base 58 encoded string. Returns a `Buffer`. | ||
**exmample**: | ||
```js | ||
var base58 = require('base58'); | ||
var address = "16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS"; | ||
var out = base58.decode(address) | ||
console.log(out.toString('hex')); // => 003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187 | ||
``` | ||
Credits | ||
@@ -26,0 +82,0 @@ ------- |
Sorry, the diff of this file is not supported yet
4788
6
57
92
2
4
+ Addedbinstring@~0.2.0
+ Addedbinstring@0.2.1(transitive)