{"id":24566219,"url":"https://github.com/archer884/crockford","last_synced_at":"2025-07-25T03:13:51.254Z","repository":{"id":27361893,"uuid":"83645706","full_name":"archer884/crockford","owner":"archer884","description":"Base32 encoding for 64-bit values.","archived":false,"fork":false,"pushed_at":"2025-03-01T20:42:39.000Z","size":78,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T10:36:15.166Z","etag":null,"topics":["base32","crockford","decoding","encoding","identifiers","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/archer884.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-02T07:00:51.000Z","updated_at":"2025-03-01T20:42:42.000Z","dependencies_parsed_at":"2022-07-27T09:32:02.755Z","dependency_job_id":null,"html_url":"https://github.com/archer884/crockford","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archer884%2Fcrockford","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archer884%2Fcrockford/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archer884%2Fcrockford/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archer884%2Fcrockford/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/archer884","download_url":"https://codeload.github.com/archer884/crockford/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250221671,"owners_count":21394745,"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":["base32","crockford","decoding","encoding","identifiers","rust"],"created_at":"2025-01-23T12:18:53.168Z","updated_at":"2025-04-22T10:36:28.931Z","avatar_url":"https://github.com/archer884.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crockford\n\n\u003e Base32 encoding for 64-bit values.\n\n[Crockford Base32 Encoding](https://www.crockford.com/wrmg/base32.html) is most commonly used to make numeric identifiers slightly more user-resistant. Similar to [Hashids](http://hashids.org/), the purpose here is to make the identifiers shorter and less confusing. Unlike Hashids, Crockford Base32 does nothing to conceal the real value of the number (beyond the actual encoding, anyway) and the fact that they are sequential is still pretty obvious when you see consecutive identifiers side by side.\n\nThis library does not support encoding and decoding of arbitrary data; there is [another library for that](https://crates.io/crates/base32). Additionally, the spec supports the idea of check digits, but this library currently does not.\n\n**The primary purpose of this library is to provide high performance, user-resistant encoding of numeric identifiers.** To that end, both encoding and decoding are, in fact, pretty darn fast. How fast? According to my testing, `crockford` decodes **fifty times faster** and encodes **twenty-seven times faster** than `harsh`. \n\n## Usage\n\n### Encoding\n\nEncoding is a one-step process.\n\n```rust\nlet x = crockford::encode(5111);\nassert_eq!(\"4ZQ\", \u0026*x);\n```\n\nIf you want lowercase, then... Well, tough. However, we do now support encoding to a buffer of your choice rather than a new one created in the function. Read on to learn about plan B...\n\n#### Plan B (faster encoding)\n\nBecause this is Rust, particular focus is given to runtime efficiency--or, at least, allowing the user to achieve runtime efficiency. As a result, we provide a second, more complicated encoding option.\n\n```rust\n// The longest possible representation of u64 is 13 digits.\nlet mut buf = Vec::with_capacity(13);\ncrockford::encode_into(5111, \u0026mut buf);\n\nlet result = std::str::from_utf8(\u0026buf)?;\nassert_eq!(\"4ZQ\", result);\n```\n\nThis `encode_into` method also accepts `\u0026mut String`, if you prefer.\n\n### Decoding\n\nDecoding is a two-step process. This is because you can feed any string to the decoder, and the decoder will return an error if you try to convince it that `\"Hello, world!\"` is a number. (Hint: it isn't.)\n\n```rust\nlet x = crockford::decode(\"4zq\");\nlet y = crockford::decode(\"4ZQ\");\n\nassert_eq!(5111, x?);\nassert_eq!(5111, y?);\n```\n\nSo, step one is to call the decode function. Step two is to match/verify/unwrap/throw away the output.\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0 ([LICENSE-APACHE][apc] or http://www.apache.org/licenses/LICENSE-2.0)\n* MIT License ([LICENSE-MIT][mit] or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n[apc]: https://github.com/archer884/crockford/blob/master/LICENSE-APACHE\n[mit]: https://github.com/archer884/crockford/blob/master/LICENSE-MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farcher884%2Fcrockford","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farcher884%2Fcrockford","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farcher884%2Fcrockford/lists"}