{"name":"hypercore-id-encoding","version":"1.0.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":"^2.3.1","hypercore":"next","random-access-memory":"^4.1.0"},"license":"MIT","gitHead":"0f048cf27534e28bd6edf5a72cf25978addf1b97","_id":"hypercore-id-encoding@1.0.0","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-9JjQopswSSzS+lc6XPD/yd/BTSZvIXH4abgvaxP44z8mnpkl/10uhcrnUKoF5nKQ/SVcg3ILITiE28fgtzI32A==","shasum":"19d2048705c222bf54535b533592a8cfe033b5a6","tarball":"http://registry-npm.ywwl.com/hypercore-id-encoding/download/hypercore-id-encoding-1.0.0.tgz","fileCount":6,"unpackedSize":749095,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSrgsN1bmbHosPCdFzjcsQnR8+W1BPemNJ8NnuRvGQ1gIhANYlIAyM30pb2MT6Sk7MyHV7BiuvjSP3bg0JxACNNOXW"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJirheIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmppTQ//UwwQuGgj52yaMP0wJeb/wNDH5O9WT8drvTsVrV8YqDW6/Jpz\r\nGIF6lib7/oVHChMSQeo40KGliol4Owg8Fle6gebftOuzixg5JWbFdW2JS9VN\r\newz6KBdQA7MYBWv0d7QytTb0EcFafE8/68UVdfyaWE45hyl5do9iAECQq0ol\r\nfkt7TVKB4seBDk/ipFZiYSUvDxCiEflQfy99Sx1+AY/ztvemcYs998JNBv3z\r\nl/ARvEIVNdw3svBG00LsYLm5LG2dpUtUWgmpBgF/vuwSemBEIL3wsGmspIh6\r\nQkCJwhtMjl2AbDJJefvP5VduwTxo8Euf5cjPPXOwfFxfDo1iJgH0yhaHRVHS\r\nTkCxQGhD3mF4RXoc2CdSYPUoxQ5Je7pHVjkxxHCuk8ugr/Fm6jTXpzLYmLcm\r\nNdc03KbVzIopq10/9xBai6Di4iTKNo6bwVdeSA++RCrt3SamvFQ5ftyTJXNU\r\n6nxdtFA0utQI05G9LkoeMYBmfKuSXU1M+sNF81GgIuIfkIEjbjCTlimVjhy6\r\nQFyFg/hxT0919qMvwtkw6uOuO0bnMVgzcC+SgIihZS3KNkM/poinwDAb0HRK\r\nA7k3nX+sGC42gfANrRNYBa6JzGYAn+6DAEkjjOfuqAZhBhQx+viPhyhzHLeo\r\ndBaUs2nV0sr84Fxc+EV5M85qD8eIeBjiwwQ=\r\n=Fn2L\r\n-----END PGP SIGNATURE-----\r\n","size":85297,"noattachment":false,"key":"/hypercore-id-encoding/-/hypercore-id-encoding-1.0.0.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.0_1655576455974_0.46053807814822356"},"_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":1655576456168,"_cnpm_publish_time":1655576456168,"dist-tags":{"latest":"1.3.0"}}