{"id":14990818,"url":"https://github.com/sqids/sqids-zig","last_synced_at":"2025-04-12T03:24:50.069Z","repository":{"id":211174870,"uuid":"726884561","full_name":"sqids/sqids-zig","owner":"sqids","description":"Official Zig port of Sqids. Generate short unique IDs from numbers.","archived":false,"fork":false,"pushed_at":"2024-12-05T14:14:06.000Z","size":43,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-25T23:01:46.194Z","etag":null,"topics":["hashids","id","id-generator","short-id","short-url","sqids","uid","unique-id","unique-id-generator","zig","zig-lang","zig-library","ziglang"],"latest_commit_sha":null,"homepage":"https://sqids.org/zig","language":"Zig","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/sqids.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-12-03T17:26:14.000Z","updated_at":"2025-03-11T03:40:42.000Z","dependencies_parsed_at":"2023-12-06T23:23:25.006Z","dependency_job_id":"2dc388ac-37c9-4b85-9e9b-1156e664ba42","html_url":"https://github.com/sqids/sqids-zig","commit_stats":null,"previous_names":["sqids/sqids-zig"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqids","download_url":"https://codeload.github.com/sqids/sqids-zig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248511092,"owners_count":21116353,"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":["hashids","id","id-generator","short-id","short-url","sqids","uid","unique-id","unique-id-generator","zig","zig-lang","zig-library","ziglang"],"created_at":"2024-09-24T14:20:54.474Z","updated_at":"2025-04-12T03:24:50.044Z","avatar_url":"https://github.com/sqids.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Sqids Zig](https://sqids.org/zig)\n\n[Sqids](https://sqids.org/zig) (*pronounced \"squids\"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast \u0026 URL-safe ID generation and decoding back into numbers for quicker database lookups.\n\nFeatures:\n\n- **Encode multiple numbers** - generate short IDs from one or several non-negative numbers\n- **Quick decoding** - easily decode IDs back into numbers\n- **Unique IDs** - generate unique IDs by shuffling the alphabet once\n- **ID padding** - provide minimum length to make IDs more uniform\n- **URL safe** - auto-generated IDs do not contain common profanity\n- **Randomized output** - Sequential input provides nonconsecutive IDs\n- **Many implementations** - Support for [multiple programming languages](https://sqids.org/)\n\n## 🧰 Use-cases\n\nGood for:\n\n- Generating IDs for public URLs (eg: link shortening)\n- Generating IDs for internal systems (eg: event tracking)\n- Decoding for quicker database lookups (eg: by primary keys)\n\nNot good for:\n\n- Sensitive data (this is not an encryption library)\n- User IDs (can be decoded revealing user count)\n\n## 🚀 Getting started\n\nTo add sqids-zig to your Zig application or library, follow these steps:\n\n1. Fetch the package at the desired commit:\n\n```terminal\nzig fetch --save https://github.com/lvignoli/sqids-zig/archive/\u003ccommitID\u003e.tar.gz\n```\n\n2. Declare the dependecy in the `build.zig.zon` file, with the hash obtained during the fetch:\n\n```zig\n.dependencies = .{\n    .sqids = .{\n        .url = \"https://github.com/lvignoli/sqids-zig/archive/\u003ccommitID\u003e.tar.gz\",\n        .hash = \"\u003chash\u003e\",\n    },\n}\n```\n\n3. In your `build.zig`, make the `sqids` module available for import:\n\n```zig\nconst sqids_dep = b.dependency(\"sqids\", .{});\nconst sqids_mod = sqids_dep.module(\"sqids\");\n\n[...]\n \nexe.addModule(\"sqids\", sqids_mod); // for an executable\nlib.addModule(\"sqids\", sqids_mod); // for a library\ntests.addModule(\"sqids\", sqids_mod); // for tests\n```\n\n4. Use it in Zig source code with:\n\n```zig\nconst sqids = @import(\"sqids\");\n```\n\n(The import string is the one provided in the `addModule` call.)\n\n\u003e [!TIP]\n\u003e Check [lvignoli/sqidify](https://github.com/lvignoli/sqidify) for a self-contained Zig executable example.\n\n## 👩‍💻 Examples\n\nSimple encode \u0026 decode:\n\n```zig\nconst s = try sqids.Sqids.init(allocator, .{})\ndefer s.deinit();\n\nconst id = try s.encode(\u0026.{1, 2, 3});\ndefer allocator.free(id); // Caller owns the memory.\n\nconst numbers = try s.decode(id);\ndefer allocator.free(numbers); // Caller owns the memory.\n```\n\n\u003e **Note**\n\u003e 🚧 Because of the algorithm's design, **multiple IDs can decode back into the same sequence of numbers**. If it's important to your design that IDs are canonical, you have to manually re-encode decoded numbers and check that the generated ID matches.\n\nThe `sqids.Options` struct is used at initialization to customize the encoder.\n\nEnforce a *minimum* length for IDs:\n\n```zig\nconst s = try sqids.Sqids.init(allocator, .{.min_length = 10});\nconst id = try s.encode(\u0026.{1, 2, 3}); // \"86Rf07xd4z\"\n```\n\nRandomize IDs by providing a custom alphabet:\n\n```zig\nconst s = try sqids.Sqids.init(allocator, .{.alphabet = \"FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE\"});\nconst id = try s.encode(\u0026.{1, 2, 3}); // \"B4aajs\"\n```\n\nPrevent specific words from appearing anywhere in the auto-generated IDs:\n\n```zig\nconst s = try sqids.Sqids.init(allocator, .{.blocklist = \u0026.{\"86Rf07\"}});\nconst id = try s.encode(\u0026.{1, 2, 3}); // \"se8ojk\"\n```\n\n## 📝 License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqids%2Fsqids-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqids%2Fsqids-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqids%2Fsqids-zig/lists"}