{"name":"hypercore-id-encoding","version":"1.1.0","description":"Convert Hypercore keys to/from z-base32 or hex","main":"index.js","scripts":{"test":"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"},"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":"5cebe1f59a417e38b2202659481c9aba63bb1bea","_id":"hypercore-id-encoding@1.1.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-5Rg5y3dRs/UcClFniGOr0zrDINNOID3zEDmAmXx632jn0Zui8W8yE0mSXFa2/b7EaVB6bGxjK4G7yDYy1U0b6w==","shasum":"c92c6b469fcfa43a865ed497b2e326c872f96efc","tarball":"http://registry-npm.ywwl.com/hypercore-id-encoding/download/hypercore-id-encoding-1.1.0.tgz","fileCount":7,"unpackedSize":16370,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCU5jwj/3or40dRn7AbcIyhAAHzc6RhLn3k2qz6/7WKcwIgJh2xLqOBmCmMhhcg5W1VpPUeQFbtwzqE1IsxkRxoF5s="}],"size":5736,"noattachment":false,"key":"/hypercore-id-encoding/-/hypercore-id-encoding-1.1.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.1.0_1686165655689_0.4096822145943968"},"_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":1686165655953,"_cnpm_publish_time":1686165655953,"dist-tags":{"latest":"1.3.0"}}