{"_id":"base-x-bytearray","_rev":"4579946","name":"base-x-bytearray","description":"Fast base encoding / decoding of any given alphabet to Uint8Array/Buffer","dist-tags":{"latest":"0.1.3"},"maintainers":[{"name":"pelleb","email":""}],"time":{"modified":"2026-04-10T15:56:36.000Z","created":"2017-02-08T21:12:04.409Z","0.1.3":"2017-03-31T17:35:52.004Z","0.1.2":"2017-03-31T15:27:47.682Z","0.1.1":"2017-03-31T14:51:53.184Z","0.1.0":"2017-02-08T21:12:04.409Z"},"users":{},"author":{"name":"Daniel Cousens"},"repository":{"type":"git","url":"git+https://github.com/cryptocoinjs/base-x.git"},"versions":{"0.1.3":{"name":"base-x-bytearray","version":"0.1.3","description":"Fast base encoding / decoding of any given alphabet to Uint8Array/Buffer","keywords":["base-x","base58","base62","base64","crypto","crytography","decode","decoding","encode","encoding"],"homepage":"https://github.com/pelle/base-x","bugs":{"url":"https://github.com/pelle/base-x/issues"},"license":"MIT","author":{"name":"Daniel Cousens"},"files":["index.js"],"main":"index.js","repository":{"type":"git","url":"git+https://github.com/cryptocoinjs/base-x.git"},"scripts":{"standard":"standard","test":"npm run unit && npm run standard","unit":"tape test/*.js"},"devDependencies":{"standard":"^6.0.8","tape":"^4.5.1"},"engines":{"node":">=4.5.0"},"gitHead":"6642fc4a177fd290f74d7126fd68c9eb1901c729","_id":"base-x-bytearray@0.1.3","_shasum":"8bbf2a4f13194d24aafa61ca94dc58ee8a663350","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.3.0","_npmUser":{"name":"pelleb","email":"pelleb@gmail.com"},"dist":{"shasum":"8bbf2a4f13194d24aafa61ca94dc58ee8a663350","size":3455,"noattachment":false,"key":"/base-x-bytearray/-/base-x-bytearray-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/base-x-bytearray/download/base-x-bytearray-0.1.3.tgz"},"maintainers":[{"name":"pelleb","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/base-x-bytearray-0.1.3.tgz_1490981750124_0.415809809230268"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T12:14:04.532Z","publish_time":1490981752004,"_cnpm_publish_time":1490981752004},"0.1.2":{"name":"base-x-bytearray","version":"0.1.2","description":"Fast base encoding / decoding of any given alphabet to Uint8Array/Buffer","keywords":["base-x","base58","base62","base64","crypto","crytography","decode","decoding","encode","encoding"],"homepage":"https://github.com/pelle/base-x","bugs":{"url":"https://github.com/pelle/base-x/issues"},"license":"MIT","author":{"name":"Daniel Cousens"},"files":["index.js"],"main":"index.js","repository":{"type":"git","url":"git+https://github.com/cryptocoinjs/base-x.git"},"scripts":{"standard":"standard","test":"npm run unit && npm run standard","unit":"tape test/*.js"},"devDependencies":{"standard":"^6.0.8","tape":"^4.5.1"},"engines":{"node":">=4.5.0"},"gitHead":"d3cce8941c399d75c343db0757c196543bacff4e","_id":"base-x-bytearray@0.1.2","_shasum":"23faa9ac44fc774762d257082efbb8e5bae02dfb","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.3.0","_npmUser":{"name":"pelleb","email":"pelleb@gmail.com"},"dist":{"shasum":"23faa9ac44fc774762d257082efbb8e5bae02dfb","size":3460,"noattachment":false,"key":"/base-x-bytearray/-/base-x-bytearray-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/base-x-bytearray/download/base-x-bytearray-0.1.2.tgz"},"maintainers":[{"name":"pelleb","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/base-x-bytearray-0.1.2.tgz_1490974065761_0.30183844664134085"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T12:14:03.661Z","publish_time":1490974067682,"_cnpm_publish_time":1490974067682},"0.1.1":{"name":"base-x-bytearray","version":"0.1.1","description":"Fast base encoding / decoding of any given alphabet to Uint8Array/Buffer","keywords":["base-x","base58","base62","base64","crypto","crytography","decode","decoding","encode","encoding"],"homepage":"https://github.com/pelle/base-x","bugs":{"url":"https://github.com/pelle/base-x/issues"},"license":"MIT","author":{"name":"Daniel Cousens"},"files":["index.js"],"main":"index.js","repository":{"type":"git","url":"git+https://github.com/cryptocoinjs/base-x.git"},"scripts":{"standard":"standard","test":"npm run unit && npm run standard","unit":"tape test/*.js"},"devDependencies":{"standard":"^6.0.8","tape":"^4.5.1"},"engines":{"node":">=4.5.0"},"gitHead":"8aa624ebc434dd98efe97a5cd134982231eb0e7b","_id":"base-x-bytearray@0.1.1","_shasum":"db08ccd12b33a4dcc527a6a255aaf7ad30a8f201","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.3.0","_npmUser":{"name":"pelleb","email":"pelleb@gmail.com"},"dist":{"shasum":"db08ccd12b33a4dcc527a6a255aaf7ad30a8f201","size":3461,"noattachment":false,"key":"/base-x-bytearray/-/base-x-bytearray-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/base-x-bytearray/download/base-x-bytearray-0.1.1.tgz"},"maintainers":[{"name":"pelleb","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/base-x-bytearray-0.1.1.tgz_1490971912546_0.8919769572094083"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T12:14:02.777Z","publish_time":1490971913184,"_cnpm_publish_time":1490971913184},"0.1.0":{"name":"base-x-bytearray","version":"0.1.0","description":"Fast base encoding / decoding of any given alphabet to Uint8Array/Buffer","keywords":["base-x","base58","base62","base64","crypto","crytography","decode","decoding","encode","encoding"],"homepage":"https://github.com/pelle/base-x","bugs":{"url":"https://github.com/pelle/base-x/issues"},"license":"MIT","author":{"name":"Daniel Cousens"},"files":["index.js"],"main":"index.js","repository":{"type":"git","url":"git+https://github.com/cryptocoinjs/base-x.git"},"scripts":{"standard":"standard","test":"npm run unit && npm run standard","unit":"tape test/*.js"},"devDependencies":{"standard":"^6.0.8","tape":"^4.5.1"},"engines":{"node":">=4.5.0"},"gitHead":"b429140700b152c3671abb0a7309764cb444ea29","_id":"base-x-bytearray@0.1.0","_shasum":"8c2c5052aeab25207b21d866e78c1b59ab65ec2a","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.3.0","_npmUser":{"name":"pelleb","email":"pelleb@gmail.com"},"dist":{"shasum":"8c2c5052aeab25207b21d866e78c1b59ab65ec2a","size":3412,"noattachment":false,"key":"/base-x-bytearray/-/base-x-bytearray-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/base-x-bytearray/download/base-x-bytearray-0.1.0.tgz"},"maintainers":[{"name":"pelleb","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/base-x-bytearray-0.1.0.tgz_1486588323843_0.701381397433579"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T12:14:01.917Z","publish_time":1486588324409,"_cnpm_publish_time":1486588324409}},"readme":"# base-x\n\n[![NPM Package](https://img.shields.io/npm/v/base-x.svg?style=flat-square)](https://www.npmjs.org/package/base-x-bytearray)\n[![Build Status](https://img.shields.io/travis/cryptocoinjs/base-x.svg?branch=master&style=flat-square)](https://travis-ci.org/pelle/base-x)\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\nFast base encoding / decoding of any given alphabet using bitcoin style leading\nzero compression.\n\nThis is forked from [cryptocoinjs/base-x](https://github.com/cryptocoinjs/base-x)\n\nAnd simply uses Uint8array if Buffer isn't already available.\n\n## Example\n\nBase58\n\n``` javascript\nvar BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\nvar bs58 = require('base-x')(BASE58)\n\nvar decoded = bs58.decode('5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr')\n\nconsole.log(decoded)\n// => <Uint8array- 80 ed db dc 11 68 f1 da ea db d3 e4 4c 1e 3f 8f 5a 28 4c 20 29 f7 8a d2 6a f9 85 83 a4 99 de 5b 19>\n\nconsole.log(bs58.encode(decoded))\n// => 5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr\n```\n\n### Alphabets\n\nSee below for a list of commonly recognized alphabets, and their respective base.\n\nBase | Alphabet\n------------- | -------------\n2 | `01`\n8 | `01234567`\n11 | `0123456789a`\n16 | `0123456789abcdef`\n32 | `0123456789ABCDEFGHJKMNPQRSTVWXYZ`\n36 | `0123456789abcdefghijklmnopqrstuvwxyz`\n58 | `123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`\n62 | `0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`\n64 | `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`\n66 | `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~`\n\n\n## How it works\n\nIt encodes octet arrays by doing long divisions on all significant digits in the\narray, creating a representation of that number in the new base. Then for every\nleading zero in the input (not significant as a number) it will encode as a\nsingle leader character. This is the first in the alphabet and will decode as 8\nbits. The other characters depend upon the base. For example, a base58 alphabet\npacks roughly 5.858 bits per character.\n\nThis means the encoded string 000f (using a 0-f alphabet) will actually decode\nto 4 bytes unlike a typical hex codec which uniformly packs 4 bits into each\ncharacter.\n\nWhile unusual, this does mean that no padding is required and it works for bases\nlike 43. If you need standard hex encoding or base64 encoding you probably don't\nwant this.\n\nThe algorithm used to convert the base of the number is roughly this:\n\n```python\nsignificant =  12345\nbase = 16\ndigits = []\nwhile significant > base:\n  significant, remainder = divmod(significant, base)\n  digits.append(remainder)\ndigits.append(significant)\nassert list(reversed(digits)) == [3,0,3,9]\nassert hex(12345) == '0x3039'\n```\n\nOf course the input is actually an array of digits already :)\n\n## License\n\nThis library is free and open-source software released under the MIT license.\n\n","_attachments":{},"homepage":"https://github.com/pelle/base-x","bugs":{"url":"https://github.com/pelle/base-x/issues"},"license":"MIT"}