{"name":"hypercore-id-encoding","version":"1.3.0","description":"Convert Hypercore keys to/from z-base32 or hex","main":"index.js","scripts":{"test":"standard && brittle test.js"},"dependencies":{"b4a":"^1.5.3","z32":"^1.0.0"},"devDependencies":{"brittle":"^3.1.1","hypercore":"^10.0.0","random-access-memory":"^6.0.0","standard":"^17.1.0"},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/holepunchto/hypercore-id-encoding.git"},"keywords":[],"author":"","bugs":{"url":"https://github.com/holepunchto/hypercore-id-encoding/issues"},"homepage":"https://github.com/holepunchto/hypercore-id-encoding#readme","_id":"hypercore-id-encoding@1.3.0","gitHead":"5607a0e308d0badebf25f32e94d3615a4c9f22ed","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-W6sHdGo5h7LXEsoWfKf/KfuROZmZRQDlGqJF2EPHW+noCK66Vvr0+zE6cL0vqQi18s0kQPeN7Sq3QyR0Ytc2VQ==","shasum":"b3822eb97bee89ac134ffea2b8b67230ca166f55","tarball":"http://registry-npm.ywwl.com/hypercore-id-encoding/download/hypercore-id-encoding-1.3.0.tgz","fileCount":4,"unpackedSize":14342,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICZ3btKklakN2aWgwzMaw3sA+TucsxxBSXgy1QN1aYzWAiEAvfNo5jg0ji1ccgow8xzG9WRgZEJ/0NLMyQ/DIRzY68g="}],"size":5248,"noattachment":false,"key":"/hypercore-id-encoding/-/hypercore-id-encoding-1.3.0.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"andrewosh","email":"andrewosh@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hypercore-id-encoding_1.3.0_1711450508067_0.8006855341535568"},"_hasShrinkwrap":false,"readme":"# hypercore-id-encoding\n\nEncodes Hypercore keys into z-base32 ids, and decodes both hex/z-base32 strings.\n\n```\nnpm install hypercore-id-encoding\n```\n\n## Usage\n\n```js\nconst { encode, decode, normalize } = require('hypercore-id-encoding')\n\nconst id = encode(core.key) // (z-base32 String)\nconst hexEncoded = core.key.toString('hex')\n\nconst core = new Hypercore(ram, decode(id)) \nconst core2 = new Hypercore(ram, decode(hexEncoded)) // Will also work with hex\n\nconst id2 = normalize(id)\nconst id3 = normalize(hexEncoded)\n```\n\n## API\n\n#### `const id = encode(hypercoreKey)`\n\nEncodes a 32-byte Hypercore key into a z-base32 id.\n\n`hypercoreKey` must be a Buffer or an ArrayBuffer.\n\n#### `const buf = decode(hypercoreId)`\n\nDecodes an id or pear link into a Hypercore key.\n\nIf `hypercoreId` is a 52-character String, it will be decoded as z-base32.\n\nIf `hypercoreId` is a 64-character String, it will be decoded as hex.\n\nIf `hypercoreId` is already a Buffer and is a valid id, it will be returned as-is.\n\n#### `const id = normalize(any)`\n\nDecodes and encodes the input `any` to always return a z-base32 id.\n\n#### `isValid(any)`\n\nReturns a boolean indicating whether the key is a valid hypercore key (meaning that it can be decoded/normalised).\n\n## License\n\nApache-2.0\n\n\n\n","publish_time":1711450508207,"_cnpm_publish_time":1711450508207,"dist-tags":{"latest":"1.3.0"}}