{"id":19032475,"url":"https://github.com/creadone/garant","last_synced_at":"2025-07-04T23:36:49.121Z","repository":{"id":56848021,"uuid":"330603876","full_name":"creadone/garant","owner":"creadone","description":"Helper for generate only unique hashes","archived":false,"fork":false,"pushed_at":"2021-01-18T14:51:48.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T23:43:20.298Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/creadone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-18T08:39:49.000Z","updated_at":"2023-03-05T00:55:52.000Z","dependencies_parsed_at":"2022-09-09T07:50:21.917Z","dependency_job_id":null,"html_url":"https://github.com/creadone/garant","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/creadone%2Fgarant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fgarant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fgarant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fgarant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creadone","download_url":"https://codeload.github.com/creadone/garant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240082637,"owners_count":19745257,"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-11-08T21:28:49.141Z","updated_at":"2025-02-21T20:27:59.700Z","avatar_url":"https://github.com/creadone.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Garant\n\nGem helps to prevent the collisions when generating a large number of hashes. For example: you decided to try Ruby module `SecureRandom`:\n\n```Ruby\nrequire 'set'\nrequire 'securerandom'\n\nNUMBER_OF_HASHES = 1_000_000\nSTORAGE = Set.new\n\nNUMBER_OF_HASHES.times do |num|\n  STORAGE \u003c\u003c SecureRandom.urlsafe_base64(4, false)\nend\n\nputs NUMBER_OF_HASHES - STORAGE.size # =\u003e 123\n```\n\nthat is, out of 1 million approximately 123 hashes will be duplicated. It's OK if uniqueness is not the goal but sometimes it's necessary to get unique hashes from a specific hash-function (see [hash function quality and speed tests](https://github.com/rurban/smhasher)).\n\nThe Garant will make sure that there are no duplicates.\n\n## Status\n\nWorking pre-alpha, not for production.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'garant'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install garant\n\n## Usage\n\n```Ruby\nrequire 'garant'\nrequire 'securerandom'\n\nGarant.setup do |s|\n  # Bloom filter params\n  s.storage_type      = :bloom  # To store unique values will be used Bloom filter.\n  s.expected_size     = 10_000  # Expected (or more) number of the hashes.\n  s.error_probability = 0.01    # The probability of false positives.\n\n  # Set params\n  s.storage_type      = :set    # To store unique values will be used Set structure.\n\n  # Common params\n  s.max_retries       = 15      # The number of attempts to regenerate the not unique hash.\nend\n\n1000.times do\n  puts Garant.safe{ SecureRandom.urlsafe_base64(4, false) }\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/creadone/garant.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreadone%2Fgarant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreadone%2Fgarant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreadone%2Fgarant/lists"}