{"id":22808187,"url":"https://github.com/sixarm/sixarm_ruby_zid","last_synced_at":"2025-06-25T19:03:31.205Z","repository":{"id":27194661,"uuid":"30664987","full_name":"SixArm/sixarm_ruby_zid","owner":"SixArm","description":"SixArm.com » Ruby » ZID: Zen Identifier","archived":false,"fork":false,"pushed_at":"2025-04-14T09:21:39.000Z","size":444,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T12:50:47.185Z","etag":null,"topics":["ruby","zid"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SixArm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-02-11T19:18:04.000Z","updated_at":"2025-04-14T09:21:43.000Z","dependencies_parsed_at":"2025-04-14T10:26:05.525Z","dependency_job_id":"f574ae32-2e95-42bf-8927-c6b83aa50e1c","html_url":"https://github.com/SixArm/sixarm_ruby_zid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SixArm/sixarm_ruby_zid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_zid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_zid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_zid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_zid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SixArm","download_url":"https://codeload.github.com/SixArm/sixarm_ruby_zid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fsixarm_ruby_zid/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260072806,"owners_count":22954926,"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":["ruby","zid"],"created_at":"2024-12-12T11:08:17.224Z","updated_at":"2025-06-16T00:09:22.173Z","avatar_url":"https://github.com/SixArm.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SixArm.com → Ruby → \u003cbr\u003e ZID: Xeno Identifier for foreign keys\n\n\u003c!--header-open--\u003e\n\n[![Gem Version](https://badge.fury.io/rb/sixarm_ruby_zid.svg)](http://badge.fury.io/rb/sixarm_ruby_zid)\n[![Build Status](https://travis-ci.org/SixArm/sixarm_ruby_zid.png)](https://travis-ci.org/SixArm/sixarm_ruby_zid)\n[![Code Climate](https://api.codeclimate.com/v1/badges/e0e205a7564fafacc365/maintainability)](https://codeclimate.com/github/SixArm/sixarm_ruby_zid/maintainability)\n\n* Git: \u003chttps://github.com/SixArm/sixarm_ruby_zid\u003e\n* Doc: \u003chttp://sixarm.com/sixarm_ruby_zid/doc\u003e\n* Gem: \u003chttps://rubygems.org/gems/sixarm_ruby_zid\u003e\n* Contact: Joel Parker Henderson, \u003cjoel@sixarm.com\u003e\n* Project: [changes](CHANGES.md), [license](LICENSE.md), [contributing](CONTRIBUTING.md).\n\n\u003c!--header-shut--\u003e\n\n\n## Introduction\n\nZID stands for \"Zen Identifier\".\n\nA ZID is a secure random id, similar to a random UUID (Universally Unique Identifier).\n\nZID specification:\n\n  * Generated entirely by using a secure random generator.\n  * You can use as many bits as you like, for example ZID128 is 128 bits.\n  * The string representation is always hexadecimal lowecase: digits 0-9 and lowercase a-f.\n\nSee below for a comparison of ZID and UUID.\n\nFor docs go to \u003chttp://sixarm.com/sixarm_ruby_zid/doc\u003e\n\nWant to help? We're happy to get pull requests.\n\n\n\u003c!--install-open--\u003e\n\n## Install\n\n### Gem\n\nTo install this gem in your shell or terminal:\n\n    gem install sixarm_ruby_zid\n\n### Gemfile\n\nTo add this gem to your Gemfile:\n\n    gem 'sixarm_ruby_zid'\n\n### Require\n\nTo require the gem in your code:\n\n    require 'sixarm_ruby_zid'\n\n\u003c!--install-shut--\u003e\n\n\n## Details\n\nClass methods:\n\n  * `ZID.generate`: generate a new ZID string.\n  * `ZID.valid?(string)`: is a string a valid ZID?\n  * `ZID.parse(object)`: parse any object to a new ZID string.\n\nNotes:\n\n  * ZID uses Ruby's SecureRandom methods for strong security.\n  * ZID generates a Ruby string, so you can do any string methods on it.\n\n\n## UUID comparison\n\nZID is much like UUID:\n\n  * ZID and UUID are both 128 bit.\n  * ZID has one form. UUID has multiple forms known as variants and versions.\n  * ZID mandates secure randomness. UUID has no mandate of secure randomness.\n  * ZID is entirely random. UUID has a non-random variant value.\n  * ZID is entirely lowercase. UUID representation and reading allows uppercase or lowercase.\n  * ZID is entirely hex digits. UUID allows dashes to separate sequences.\n  * ZID is always 32 characters. UUID allows 32-36 characters.\n\nTo format an ZID in the style of a UUID canonical representation:\n\n    zid = \"90f44e35a062479289ff75ab2abc0ed3\"\n    zid.sub(/(.{8})(.{4})(.{4})(.{16})/,\"#$1-#$2-#$3-#$4\")\n    #=\u003e \"90f44e35-a062-4792-89ff75ab2abc0ed3\"\n\nNote: the result string is formatted like a UUID, but is not guaranteed to be valid UUID. This is because the ZID is random, whereas the UUID specification requires a specific bit that indicates the UUID is random.\n\nTo format a UUID in the style of an ZID:\n\n    uuid = \"14fFE137-2DB2-4A37-A2A4-A04DB1C756CA\"\n    uuid.gsub(/-/,\"\").downcase\n    #=\u003e \"\"14f7e1372db24a37a2a4a04db1c756ca\"\n\nNote: the result string is formatted like a ZID, but is not a valid ZID. This is because there's no guarantee that the UUID was randomly generated using a secure random generator, and also because the UUID-4 specification requires a random UUID to set the third section's first digit to 4.\n\n\n## Unix tooling\n\nTo generate an ZID on a typical Unix system, one way is the hexdump command:\n\n    $ hexdump -n 16 -v -e '16/1 \"%02x\" \"\\n\"' /dev/random\n    b29dd48b7040f788fd926ebf1f4eddd0\n\nTo digest an ZID by using SHA256:\n\n    $ echo -n \"b29dd48b7040f788fd926ebf1f4eddd0\" | shasum -a 256\n    afdfb0400e479285040e541ee87d9227d5731a7232ecfa5a07074ee0ad171c64\n\n\n## Database tooling\n\nTo store an ZID in a database, one way is using a string field that is 32 characters long.\n\nSome databases have specialize fields for 128 bit values, such as PostgreSQL and its UUID extensions. PostgreSQL states that a UUID field will accept a string that is lowercase and that omits dashes. PostgreSQL does not do any validity-checking on the UUID value. Thus it is viable to store an ZID in a UUID field. Our team has a goal to create a PostgreSQL extension for the ZID data type.\n\n## Credits\n\n* [Joel Parker Henderson](https://github.com/joelparkerhenderson)\n* [Michael Pope](https://github.com/amorphid)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixarm%2Fsixarm_ruby_zid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsixarm%2Fsixarm_ruby_zid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixarm%2Fsixarm_ruby_zid/lists"}