{"name":"hypercore-id-encoding","version":"1.0.1","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":"^2.3.1","hypercore":"next","random-access-memory":"^4.1.0"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/hypercore-protocol/hypercore-id-encoding.git"},"keywords":[],"author":"","bugs":{"url":"https://github.com/hypercore-protocol/hypercore-id-encoding/issues"},"homepage":"https://github.com/hypercore-protocol/hypercore-id-encoding#readme","gitHead":"0a519b94e73020c3584adcba68d19dbe3da1a7c2","_id":"hypercore-id-encoding@1.0.1","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-qTZIKbHRmYwHhRnT+eInmf4c2SDPXe1D+FotXQpBL3wvGZTVKqiENoSg+K4xYhw5EP/SUBACvpoL4fXXEFz9bw==","shasum":"217bb793da791a6019850b576d3cee361f896e22","tarball":"http://registry-npm.ywwl.com/hypercore-id-encoding/download/hypercore-id-encoding-1.0.1.tgz","fileCount":6,"unpackedSize":761022,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICvGo7rUwmmbaeU2Gdi7Gzkz7q+VfqtmnKT7Tki6ci9CAiACGCXJb++EpcvnvcWFtCGgC2nPGCcqKyON+6NHpoSjnw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYmN5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpTFA//QVpjuD/KLE8r4Wxbf8NeW8kURozOxNw5X60uEiHGxmiy1jjp\r\nITjMrf7ySgigP5z/dQA2SpZJpTOlM3Hlhrg1UPEB3j3cPhCvZ51ekRp/Sh7y\r\nIQ50WcCgmzrFr2nBL64Y7+eHyhUXXQfk8ddkJhrizst2u85bLQTV+pqKR8W+\r\nKJDXWoiMaKtH7B4CZBWaHbvCaYc0oh22rvHSlp1AEF1S1KGcZL+JF/PYnrQF\r\nTOqjsmPzHKleIENSJcOSNFD1/DIAbkTg/DOUS3jumsgX35H2d7Nzg7AisSve\r\njfGzCgmeUUO+o30SGPclQ0oznpS2i1hXtZ+tm5kaIqWDVk8/bm1kvgtQ+Moz\r\nQ0k8JmjarWSw8doktlZxMJEdX0mgCM00Z0i5bFkcEOLrlHEDZzFIGLBMvox3\r\n6q/oxuqzp8CnbN3pExiNud1eHQiAzkEtnXuQKCUNX8cI1G2KWLLKfF2TUIpQ\r\niwVY4Og3EwUIs8zKGSs8ZrinY2rtXj9Kj0UF56Ntcc1N4XaUK5FoZw/3U/wE\r\ngZgYwifs665HrMtC74c1MdsZmwUHIhje89NsgC7DQaWc1PTjCwH2BO6beVxF\r\nnr054u4StiHJxKCKs5X4+mt3s6y2iqfj2UKXIRr8n7DabMqglrihaX+jcG3K\r\n7brmtwxNZc8nhVVPLIpzPp/xhPx4PhcG0+E=\r\n=bjrp\r\n-----END PGP SIGNATURE-----\r\n","size":86517,"noattachment":false,"key":"/hypercore-id-encoding/-/hypercore-id-encoding-1.0.1.tgz"},"_npmUser":{"name":"andrewosh","email":"andrewosh@gmail.com"},"directories":{},"maintainers":[{"name":"andrewosh","email":"andrewosh@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hypercore-id-encoding_1.0.1_1667392377409_0.27084505589498664"},"_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":1667392377593,"_cnpm_publish_time":1667392377593,"dist-tags":{"latest":"1.3.0"}}