{"name":"hypercore-id-encoding","version":"1.0.2","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":"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":"98ab701305e50929f7aad9c646a7b53a78b90694","_id":"hypercore-id-encoding@1.0.2","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"integrity":"sha512-ypj37Y2pWo8F6yr+PC3W/FYkAiZCTESOzdMVHZWBWuMOUWaeC1TQooAZbbmISZQuF/qvUuNDhhONL1xhtcc0Jg==","shasum":"93b0db384680747489ad0a6d26bd70540b9bf8bf","tarball":"http://registry-npm.ywwl.com/hypercore-id-encoding/download/hypercore-id-encoding-1.0.2.tgz","fileCount":5,"unpackedSize":4538,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD0jaJ362bnSCXFO3rcIqk24FA6b8H+RWg4H87o6biz5QIgLbz+gidecqeIgVW8s3KE6dZH22zLZTBEsV11yQQc+KI="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjaXCiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo6cA/8CaeIj/l4RjI3vbEvmBjd1DjcQIWODOr3vuCnozYcvVIcK/QD\r\nonNvEGbdLe64bEKZFfV+MkHvParEwg8fK0z4vsnE7wvGHYsIfzHzfN7dln7v\r\nDHs2WkBgnHhTSVT0v2mbPIwgbstAVaGGUlSLkqWaYelgGBF9ReujblsVY8oH\r\nsHn5L8d3vvRvuaqRDT6f9MTeh8CFrt3G0dAzLeqzsnv01tA9ArpOhpAMCIQO\r\n8WtGbgvclQG66ue7Ey9q8/+m9DeRod+HQmTG9xmm0wRoO1ckLAqRyhXcVUd2\r\nGTiwKycoSZzuQCw5Z0EQjgfdpzb3mwh+Xze2lOt/IMiG8CVN1wY+uLQpyXTx\r\n4zjIIIvkzkfIByQEgZvYhOJTf0s02ufvh0sxCZ0h3OzdyFs+5OSyoP3QCRtP\r\nCxz4kJ4lNRBFtUJvaFJr9LvSWBHygeN5H6U+l5eL0k99qcnn9uFjlfNy7UtV\r\n04o68HCv8xbJ4jZLHqRmvGvbE/nmxOCdvXXFLv+WG4qQcMXOcuVXWsh7xL8z\r\nAZMUqH4nKfNqHrusVfibiSsL4EDapr0poJyxf1oinim3nVLP9t1wUhlETKn6\r\nEs4KWOZ8XhnNOrIGX4tBhOkfCzXM6NTjPe6PJ1ItDkYomLfyOj2xlsv2TRL1\r\nCDG4T0Yi/vGHj0ip+vTRE6dtxHSmTtMOkrk=\r\n=f8wP\r\n-----END PGP SIGNATURE-----\r\n","size":2043,"noattachment":false,"key":"/hypercore-id-encoding/-/hypercore-id-encoding-1.0.2.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.0.2_1667854497997_0.6750666229778173"},"_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":1667854498142,"_cnpm_publish_time":1667854498142,"dist-tags":{"latest":"1.3.0"}}