pax_global_header00006660000000000000000000000064131134463750014521gustar00rootroot0000000000000052 comment=a1d5dadc1e3544c6852648776179629f96efd1d6 bs58-4.0.1/000077500000000000000000000000001311344637500123045ustar00rootroot00000000000000bs58-4.0.1/.gitignore000066400000000000000000000000411311344637500142670ustar00rootroot00000000000000node_modules/ .DS_Store coverage/bs58-4.0.1/.travis.yml000066400000000000000000000003151311344637500144140ustar00rootroot00000000000000sudo: false language: node_js node_js: - "4" - "5" - "6" - "7" env: matrix: - TEST_SUITE=unit matrix: include: - node_js: "6" env: TEST_SUITE=standard script: npm run $TEST_SUITE bs58-4.0.1/CHANGELOG.md000066400000000000000000000036361311344637500141250ustar00rootroot000000000000004.0.0 / 2016-12-3 ------------------ - `decode` now returns a `Buffer` again, to avoid potential cryptographic errors. [Daniel Cousens / #21](https://github.com/cryptocoinjs/bs58/pull/21) 3.0.0 / 2015-08-18 ------------------ - refactored module into generic [`base-x`](https://github.com/cryptocoinjs/base-x). 2.0.1 / 2014-12-23 ------------------ - performance boost in `encode()` [#10](https://github.com/cryptocoinjs/bs58/pull/10) 2.0.0 / 2014-10-03 ------------------ - `decode` now returns an `Array` instead of `Buffer` to keep things simple. [Daniel Cousens / #9](https://github.com/cryptocoinjs/bs58/pull/9) 1.2.1 / 2014-07-24 ------------------ * speed optimizations [Daniel Cousens / #8](https://github.com/cryptocoinjs/bs58/pull/8) 1.2.0 / 2014-06-29 ------------------ * removed `bigi` dep, implemented direct byte conversion [Jared Deckard / #6](https://github.com/cryptocoinjs/bs58/pull/6) 1.1.0 / 2014-06-26 ------------------ * user `Buffer` internally for calculations, providing cleaner code and a performance increase. [Daniel Cousens](https://github.com/cryptocoinjs/bs58/commit/129c71de8bc1e36f113bce06da0616066f41c5ca) 1.0.0 / 2014-05-27 ------------------ * removed `binstring` dep, `Buffer` now only input to `encode()` and output of `decode()` * update `bigi` from `~0.3.0` to `^1.1.0` * added travis-ci support * added coveralls support * modified tests and library to handle fixture style testing (thanks to bitcoinjs-lib devs and [Daniel Cousens](https://github.com/dcousens)) 0.3.0 / 2014-02-24 ------------------ * duck type input to `encode` and change output of `decode` to `Buffer`. 0.2.1 / 2014-02-24 ------------------ * removed bower and component support. Closes #1 * convert from 4 spaces to 2 0.2.0 / 2013-12-07 ------------------ * renamed from `cryptocoin-base58` to `bs58` 0.1.0 / 2013-11-20 ------------------ * removed AMD support 0.0.1 / 2013-11-04 ------------------ * initial release bs58-4.0.1/README.md000066400000000000000000000034261311344637500135700ustar00rootroot00000000000000bs58 ==== [![build status](https://travis-ci.org/cryptocoinjs/bs58.svg)](https://travis-ci.org/cryptocoinjs/bs58) JavaScript component to compute base 58 encoding. This encoding is typically used for crypto currencies such as Bitcoin. **Note:** If you're looking for **base 58 check** encoding, see: [https://github.com/bitcoinjs/bs58check](https://github.com/bitcoinjs/bs58check), which depends upon this library. Install ------- npm i --save bs58 API --- ### encode(input) `input` must be a [Buffer](https://nodejs.org/api/buffer.html) or an `Array`. It returns a `string`. **example**: ```js const bs58 = require('bs58') const bytes = Buffer.from('003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187', 'hex') const address = bs58.encode(bytes) console.log(address) // => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS ``` ### decode(input) `input` must be a base 58 encoded string. Returns a [Buffer](https://nodejs.org/api/buffer.html). **example**: ```js const bs58 = require('bs58') const address = '16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS' const bytes = bs58.decode(address) console.log(out.toString('hex')) // => 003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187 ``` Hack / Test ----------- Uses JavaScript standard style. Read more: [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) Credits ------- - [Mike Hearn](https://github.com/mikehearn) for original Java implementation - [Stefan Thomas](https://github.com/justmoon) for porting to JavaScript - [Stephan Pair](https://github.com/gasteve) for buffer improvements - [Daniel Cousens](https://github.com/dcousens) for cleanup and merging improvements from bitcoinjs-lib - [Jared Deckard](https://github.com/deckar01) for killing `bigi` as a dependency License ------- MIT bs58-4.0.1/index.js000066400000000000000000000002141311344637500137460ustar00rootroot00000000000000var basex = require('base-x') var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' module.exports = basex(ALPHABET) bs58-4.0.1/package.json000066400000000000000000000012331311344637500145710ustar00rootroot00000000000000{ "name": "bs58", "version": "4.0.1", "description": "Base 58 encoding / decoding", "keywords": [ "base58", "bitcoin", "crypto", "crytography", "decode", "decoding", "encode", "encoding", "litecoin" ], "license": "MIT", "devDependencies": { "standard": "*", "tape": "^4.6.3" }, "repository": { "url": "https://github.com/cryptocoinjs/bs58", "type": "git" }, "files": [ "./index.js" ], "main": "./index.js", "scripts": { "standard": "standard", "test": "npm run standard && npm run unit", "unit": "tape test/index.js" }, "dependencies": { "base-x": "^3.0.2" } } bs58-4.0.1/test/000077500000000000000000000000001311344637500132635ustar00rootroot00000000000000bs58-4.0.1/test/fixtures.json000066400000000000000000000032711311344637500160320ustar00rootroot00000000000000{ "valid": [ { "hex": "", "string": "" }, { "hex": "61", "string": "2g" }, { "hex": "626262", "string": "a3gV" }, { "hex": "636363", "string": "aPEr" }, { "hex": "73696d706c792061206c6f6e6720737472696e67", "string": "2cFupjhnEsSn59qHXstmK2ffpLv2" }, { "hex": "00eb15231dfceb60925886b67d065299925915aeb172c06647", "string": "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L" }, { "hex": "516b6fcd0f", "string": "ABnLTmg" }, { "hex": "bf4f89001e670274dd", "string": "3SEo3LWLoPntC" }, { "hex": "572e4794", "string": "3EFU7m" }, { "hex": "ecac89cad93923c02321", "string": "EJDM8drfXA6uyA" }, { "hex": "10c8511e", "string": "Rt5zm" }, { "hex": "00000000000000000000", "string": "1111111111" }, { "hex": "801184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd206ec97e", "string": "5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD" }, { "hex": "003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187", "string": "16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS" } ], "invalid": [ { "description": "non-base58 string", "string": "invalid" }, { "description": "non-base58 alphabet", "string": "c2F0b3NoaQo=" }, { "description": "leading whitespace", "string": " 1111111111" }, { "description": "trailing whitespace", "string": "1111111111 " }, { "description": "unexpected character after whitespace", "string": " \t\n\u000b\f\r skip \r\f\u000b\n\t a" } ] }bs58-4.0.1/test/index.js000066400000000000000000000016441311344637500147350ustar00rootroot00000000000000var test = require('tape') var base58 = require('../') var fixtures = require('./fixtures.json') test('base58', function (t) { t.test('encode', function (t) { fixtures.valid.forEach(function (f) { t.test('can encode ' + f.hex, function (t) { var actual = base58.encode(Buffer.from(f.hex, 'hex')) t.equal(actual, f.string) t.end() }) }) t.end() }) t.test('decode', function (t) { fixtures.valid.forEach(function (f) { t.test('can decode ' + f.string, function (t) { var actual = base58.decode(f.string).toString('hex') t.same(actual, f.hex) t.end() }) }) fixtures.invalid.forEach(function (f) { t.test('throws on ' + f.description, function (t) { t.throws(function () { base58.decode(f.string) }, /^Error: Non-base58 character$/) t.end() }) }) t.end() }) t.end() })