{"id":16561487,"url":"https://github.com/jcnelson/z32check","last_synced_at":"2025-09-20T23:02:40.670Z","repository":{"id":57405093,"uuid":"138651409","full_name":"jcnelson/z32check","owner":"jcnelson","description":"z-base-32 encoding with 4-byte checksum","archived":false,"fork":false,"pushed_at":"2018-06-29T03:52:05.000Z","size":14,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-15T14:41:31.814Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcnelson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-25T21:20:38.000Z","updated_at":"2018-06-29T03:52:07.000Z","dependencies_parsed_at":"2022-09-16T09:01:22.270Z","dependency_job_id":null,"html_url":"https://github.com/jcnelson/z32check","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcnelson%2Fz32check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcnelson%2Fz32check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcnelson%2Fz32check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcnelson%2Fz32check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcnelson","download_url":"https://codeload.github.com/jcnelson/z32check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241966985,"owners_count":20050324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T20:33:18.183Z","updated_at":"2025-09-20T23:02:35.559Z","avatar_url":"https://github.com/jcnelson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# z32check\n\n[z-base-32](https://en.wikipedia.org/wiki/Base32#z-base-32) encoding library\nwith 4-byte checksum.\n\nThis library is meant for generating and decoding Stacks addresses on the\nBlockstack blockchain.\n\n## How it works\n\nEach z32check string encodes a 1-byte version and a 4-byte checksum.  When\ndecoded as a hex string, the wire format looks like this:\n\n```\n0      1                             n+1             n+5\n|------|-----------------------------|---------------|\nversion     n-byte hex payload          4-byte hash\n```\n\nIf `version` is the version byte (a 1-byte `number`) and `payload` is the raw \nbytes (e.g. as a `string`), then the `checksum` is calculated as follows:\n\n```\nchecksum = sha256(sha256(version + payload)).substring(0,4)\n```\n\nIn other words, the checksum is the first four bytes of the\ndouble-sha256 of the bytestring concatenation of the `version` and `payload`.\nThis is similar to base58check encoding, for example.\n\n## z32 Addresses\n\nSpecific to Blockstack, the Stacks blockchain uses z32-encoded public key\nhashes as addresses.  Specifically, a **z32 address** is a z32-encoded\nripemd160 hash, where the first character is capitalized (note that the \nz-base-32 alphabet does _not_ have capital letters).\n\n# Examples\n\n```\n\u003e z32 = require('z32check')\n{ z32encode: [Function: z32encode],\n  z32decode: [Function: z32decode],\n  z32checkEncode: [Function: z32checkEncode],\n  z32checkDecode: [Function: z32checkDecode],\n  z32address: [Function: z32address],\n  z32addressDecode: [Function: z32addressDecode],\n  versions: \n   { mainnet: { p2pkh: 22, p2sh: 11 },\n     testnet: { p2pkh: 17, p2sh: 2 } } }\n```\n\n## z32encode, z32decode\n\n```\n\u003e z32check.z32encode(Buffer.from('hello world').toString('hex'))\n'decisga53yq7zzr5dr'\n\u003e z32check.z32decode('decisga53yq7zzr5dr')\n'68656c6c6f20776f726c64'\n\u003e Buffer.from('68656c6c6f20776f726c64', 'hex').toString()\n'hello world'\n```\n\n## z32checkEncode, z32checkDecode\n\n```\n\u003e version = 12\n12\n\u003e z32check.z32checkEncode(version, Buffer.from('hello world').toString('hex'))\n'cpb1sa5dxrb5s6huccoawk3ce'\n\u003e z32check.z32checkDecode('cpb1sa5dxrb5s6huccoawk3ce')\n[ 12, '68656c6c6f20776f726c64' ] \n\u003e Buffer.from('68656c6c6f20776f726c64', 'hex').toString()\n'hello world'\n```\n\n# z32address, z32addressDecode\n\n**NOTE**: these methods only work on ripemd160 hashes\n\n```\n\u003e hash160 = 'a46ff88886c2ef9762d970b4d2c63678835bd39d'\n'a46ff88886c2ef9762d970b4d2c63678835bd39d'\n\u003e version = z32check.versions.mainnet.p2pkh\n22\n\u003e z32check.z32address(version, hash160)\n'Sn1g96reo5bq9f5n5famjwsgg3hegs6uuia5jq18'\n\u003e z32check.z32addressDecode('Sn1g96reo5bq9f5n5famjwsgg3hegs6uuia5jq18')\n[ 22, 'a46ff88886c2ef9762d970b4d2c63678835bd39d' ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcnelson%2Fz32check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcnelson%2Fz32check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcnelson%2Fz32check/lists"}