{"name":"hypercore-id-encoding","version":"1.2.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","gitHead":"b46135618edca4dde522de3223510a5bdc855e81","_id":"hypercore-id-encoding@1.2.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-WqPBJ/HZ/sifoo9jYw/ZUr1Z1l4kll8hQwVdDhVqsDyYPj0c/Tl0ALLXbDxb9vcpKBV+WLgLqf8kVB0GcZU0Mg==","shasum":"b801540fbd2575977e2f92e60421e51ded1b45dc","tarball":"http://registry-npm.ywwl.com/hypercore-id-encoding/download/hypercore-id-encoding-1.2.0.tgz","fileCount":4,"unpackedSize":14264,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC4+zvAcptiBGcM8G6vSkZTSkifvG0POjtr39vtX6KHewIgOE9wllpS4g4p4qG1wef4TEtTdve3bwuAyn2+FGwAO4E="}],"size":5209,"noattachment":false,"key":"/hypercore-id-encoding/-/hypercore-id-encoding-1.2.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.2.0_1690291710272_0.3605565394443664"},"_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":1690291710448,"_cnpm_publish_time":1690291710448,"dist-tags":{"latest":"1.3.0"}}