{"id":13877986,"url":"https://github.com/sqids/sqids-ruby","last_synced_at":"2025-12-29T23:37:52.264Z","repository":{"id":176746997,"uuid":"658041838","full_name":"sqids/sqids-ruby","owner":"sqids","description":"Official Ruby port of Sqids. Generate short unique IDs from numbers.","archived":false,"fork":false,"pushed_at":"2024-07-25T22:55:36.000Z","size":33,"stargazers_count":116,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-08-07T08:09:42.162Z","etag":null,"topics":["hashids","id","id-generator","ruby","short-id","short-url","sqids","uid","unique-id","unique-id-generator"],"latest_commit_sha":null,"homepage":"https://sqids.org/ruby","language":"Ruby","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":"CHANGELOG.md","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}},"created_at":"2023-06-24T15:28:41.000Z","updated_at":"2024-08-07T08:09:42.163Z","dependencies_parsed_at":null,"dependency_job_id":"8ff081cf-aebd-4a73-ad87-c8b6982f6957","html_url":"https://github.com/sqids/sqids-ruby","commit_stats":null,"previous_names":["sqids/sqids-ruby"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqids","download_url":"https://codeload.github.com/sqids/sqids-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226134226,"owners_count":17578778,"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","ruby","short-id","short-url","sqids","uid","unique-id","unique-id-generator"],"created_at":"2024-08-06T08:01:36.759Z","updated_at":"2025-12-29T23:37:52.222Z","avatar_url":"https://github.com/sqids.png","language":"Ruby","readme":"# [Sqids Ruby](https://sqids.org/ruby)\n\n[![Gem Version](https://badge.fury.io/rb/sqids.svg)](https://rubygems.org/gems/sqids)\n[![Github Actions](https://img.shields.io/github/actions/workflow/status/sqids/sqids-ruby/tests.yml)](https://github.com/sqids/sqids-ruby/actions)\n[![Downloads](https://img.shields.io/gem/dt/sqids)](https://crates.io/crates/sqids)\n\n[Sqids](https://sqids.org/ruby) (*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 [40+ 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\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'sqids'\n```\n\nAnd then execute:\n\n```bash\nbundle\n```\n\nOr install it via:\n\n```bash\ngem install sqids\n```\n\n## 👩‍💻 Examples\n\nSimple encode \u0026 decode:\n\n```ruby\nsqids = Sqids.new\nid = sqids.encode([1, 2, 3]) # '86Rf07'\nnumbers = sqids.decode(id) # [1, 2, 3]\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\nEnforce a *minimum* length for IDs:\n\n```ruby\nsqids = Sqids.new(min_length: 10)\nid = sqids.encode([1, 2, 3]) # '86Rf07xd4z'\nnumbers = sqids.decode(id) # [1, 2, 3]\n```\n\nRandomize IDs by providing a custom alphabet:\n\n```ruby\nsqids = Sqids.new(alphabet: 'FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE')\nid = sqids.encode([1, 2, 3]) # 'B4aajs'\nnumbers = sqids.decode(id) # [1, 2, 3]\n```\n\nPrevent specific words from appearing anywhere in the auto-generated IDs:\n\n```ruby\nsqids = Sqids.new(blocklist: Set.new(%w[86Rf07]))\nid = sqids.encode([1, 2, 3]) # 'se8ojk'\nnumbers = sqids.decode(id) # [1, 2, 3]\n```\n\n\u003e [!WARNING]  \n\u003e If you provide a large custom blocklist and/or custom alphabet, calls to `Sqids.new` can take \n\u003e ~1ms. You should create a singleton instance of `Sqids` at service start and reusing that rather than\n\u003e repeatedly calling `Sqids.new`\n\n## 📝 License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqids%2Fsqids-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqids%2Fsqids-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqids%2Fsqids-ruby/lists"}