{"id":15713635,"url":"https://github.com/wout/bech32","last_synced_at":"2025-03-30T18:47:37.326Z","repository":{"id":136330662,"uuid":"592669343","full_name":"wout/bech32","owner":"wout","description":"A BIP173/BIP350 compatible Bech32/Bech32m encoding/decoding library for Crystal.","archived":false,"fork":false,"pushed_at":"2024-04-19T16:52:46.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T21:26:57.221Z","etag":null,"topics":["bech32","bech32m","bip173","bip350","cardano","crystal","crystal-lang","decoder","encoder","words"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/wout.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-24T09:10:07.000Z","updated_at":"2023-11-27T01:05:44.000Z","dependencies_parsed_at":"2024-10-24T10:51:44.239Z","dependency_job_id":"5889f36c-e752-4b1e-981b-3f547a1048cf","html_url":"https://github.com/wout/bech32","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fbech32","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fbech32/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fbech32/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fbech32/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wout","download_url":"https://codeload.github.com/wout/bech32/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365639,"owners_count":20765546,"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":["bech32","bech32m","bip173","bip350","cardano","crystal","crystal-lang","decoder","encoder","words"],"created_at":"2024-10-03T21:32:34.259Z","updated_at":"2025-03-30T18:47:36.692Z","avatar_url":"https://github.com/wout.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bech32\n\nA BIP173/BIP350 compatible Bech32/Bech32m encoding/decoding library for Crystal.\n\n![GitHub](https://img.shields.io/github/license/wout/bech32)\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/wout/bech32)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/wout/bech32/ci.yml?branch=main)\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n  ```yaml\n  dependencies:\n    bech32:\n      github: wout/bech32\n  ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"bech32\"\n```\n\n### Decoding\n\nDecode using the default `Bech32` encoding:\n\n```crystal\nprefix, words = Bech32.decode(\"abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw\")\nputs prefix\n# =\u003e \"abcdef\"\nputs words\n# =\u003e Bytes[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]\n```\n\nDecode using the `Bech32M` encoding:\n\n```crystal\nprefix, words = Bech32.decode(\n  \"abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx\",\n  encoding: Bech32::Encoding::Bech32M\n)\nputs prefix\n# =\u003e \"abcdef\"\nputs words\n# =\u003e Bytes[31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n```\n\nTo convert the words to bytes:\n\n```crystal\nwords = Bytes[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]\nBech32.from_words(words)\n# =\u003e Bytes[0, 68, 50, 20, 199, 66, 84, 182, 53, 207, 132, 101, 58, 86, 215, 198, 117, 190, 119, 223]\n```\n\n### Encoding\n\nConvert the string to words:\n\n```crystal\nwords = Bech32.to_words(\"foobar\".to_slice)\n```\n\nEncode using the default `Bech32` encoding:\n\n```crystal\nBech32.encode(\"foo\", words)\n# =\u003e \"foo1vehk7cnpwgry9h96\"\n```\n\nEncode using the `Bech32M` encoding:\n\n```crystal\nBech32.encode(\"foo\", words, encoding: Bech32::Encoding::Bech32M)\n# =\u003e \"foo1vehk7cnpwgkc4mqc\"\n```\n\n### Advanced\nBIP173 enforces a limitation of 90 characters. If the given string exceeds this\nlength, pass a higher value using the `limit` argument. Be aware that the\n[effectiveness of the checksum decreases as the length\nincreases](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#checksum-design).\n\nIt is highly recommended not to exceed 1023 characters, as the module could only\nguarantee to detect one error.\n\n## Development\n\nMake sure you have [Guardian.cr](https://github.com/f/guardian) installed. Then\nrun:\n\n```bash\n$ guardian\n```\n\nThis will automatically:\n- run ameba for src and spec files\n- run the relevant spec for any file in the src dir\n- run spec a file whenever it's saved\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/wout/bech32/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Wout](https://github.com/wout) - creator and maintainer\n\n## Acknowledgments\nThis shard pulls inspiration from the following projects:\n- [bitcoinjs/bech32](https://github.com/bitcoinjs/bech32)\n- [azuchi/bech32rb](https://github.com/azuchi/bech32rb)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwout%2Fbech32","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwout%2Fbech32","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwout%2Fbech32/lists"}