sixarm_ruby_zid

SixArm.com » Ruby » ZID: Zen Identifier

https://github.com/sixarm/sixarm_ruby_zid

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary

Keywords

ruby zid
Last synced: 4 months ago · JSON representation ·

Repository

SixArm.com » Ruby » ZID: Zen Identifier

Basic Info
  • Host: GitHub
  • Owner: SixArm
  • License: other
  • Language: Ruby
  • Default Branch: main
  • Homepage:
  • Size: 434 KB
Statistics
  • Stars: 4
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Topics
ruby zid
Created almost 11 years ago · Last pushed 9 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Codeowners

README.md

SixArm.com → Ruby →
ZID: Xeno Identifier for foreign keys

Gem Version Build Status Code Climate

Introduction

ZID stands for "Zen Identifier".

A ZID is a secure random id, similar to a random UUID (Universally Unique Identifier).

ZID specification:

  • Generated entirely by using a secure random generator.
  • You can use as many bits as you like, for example ZID128 is 128 bits.
  • The string representation is always hexadecimal lowecase: digits 0-9 and lowercase a-f.

See below for a comparison of ZID and UUID.

For docs go to http://sixarm.com/sixarm_ruby_zid/doc

Want to help? We're happy to get pull requests.

Install

Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_zid

Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_zid'

Require

To require the gem in your code:

require 'sixarm_ruby_zid'

Details

Class methods:

  • ZID.generate: generate a new ZID string.
  • ZID.valid?(string): is a string a valid ZID?
  • ZID.parse(object): parse any object to a new ZID string.

Notes:

  • ZID uses Ruby's SecureRandom methods for strong security.
  • ZID generates a Ruby string, so you can do any string methods on it.

UUID comparison

ZID is much like UUID:

  • ZID and UUID are both 128 bit.
  • ZID has one form. UUID has multiple forms known as variants and versions.
  • ZID mandates secure randomness. UUID has no mandate of secure randomness.
  • ZID is entirely random. UUID has a non-random variant value.
  • ZID is entirely lowercase. UUID representation and reading allows uppercase or lowercase.
  • ZID is entirely hex digits. UUID allows dashes to separate sequences.
  • ZID is always 32 characters. UUID allows 32-36 characters.

To format an ZID in the style of a UUID canonical representation:

zid = "90f44e35a062479289ff75ab2abc0ed3"
zid.sub(/(.{8})(.{4})(.{4})(.{16})/,"#$1-#$2-#$3-#$4")
#=> "90f44e35-a062-4792-89ff75ab2abc0ed3"

Note: 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.

To format a UUID in the style of an ZID:

uuid = "14fFE137-2DB2-4A37-A2A4-A04DB1C756CA"
uuid.gsub(/-/,"").downcase
#=> ""14f7e1372db24a37a2a4a04db1c756ca"

Note: 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.

Unix tooling

To generate an ZID on a typical Unix system, one way is the hexdump command:

$ hexdump -n 16 -v -e '16/1 "%02x" "\n"' /dev/random
b29dd48b7040f788fd926ebf1f4eddd0

To digest an ZID by using SHA256:

$ echo -n "b29dd48b7040f788fd926ebf1f4eddd0" | shasum -a 256
afdfb0400e479285040e541ee87d9227d5731a7232ecfa5a07074ee0ad171c64

Database tooling

To store an ZID in a database, one way is using a string field that is 32 characters long.

Some 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.

Credits

Owner

  • Name: SixArm
  • Login: SixArm
  • Kind: organization
  • Email: sixarm@sixarm.com
  • Location: San Francisco

SixArm Software

Citation (CITATION.cff)

cff-version: 1.2.0
title: SixArm.com → Ruby → <br> ZID: Xeno Identifier for foreign keys
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/SixArm/sixarm_ruby_zid/'
    description: SixArm.com → Ruby → <br> ZID: Xeno Identifier for foreign keys
repository-code: 'https://github.com/SixArm/sixarm_ruby_zid/'
abstract: >-
  SixArm.com → Ruby → <br> ZID: Xeno Identifier for foreign keys
license: See license file

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 110
  • Total Committers: 1
  • Avg Commits per committer: 110.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 110
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

sixarm_ruby_zid.gemspec rubygems
  • flay >= 2.12.0, < 3 development
  • flog >= 4.6.2, < 5 development
  • minitest >= 5.11.3, < 6 development
  • rake >= 12.3.1, < 13 development
  • reek >= 4.8.1, < 5 development
  • rubocop >= 0.57.2, < 1 development
  • rubycritic >= 3.4.0, < 4 development
  • simplecov >= 0.16.1, < 2 development
  • sixarm_ruby_minitest_extensions >= 1.0.8, < 2 development
.github/workflows/ruby.yml actions
  • actions/checkout v3 composite
  • ruby/setup-ruby v1 composite
Gemfile rubygems
Gemfile.lock rubygems
  • addressable 2.8.4
  • ast 2.4.2
  • axiom-types 0.1.1
  • bundler 2.3.26
  • codeclimate-engine-rb 0.4.2
  • coercible 1.0.0
  • descendants_tracker 0.0.4
  • docile 1.4.0
  • equalizer 0.0.11
  • erubi 1.12.0
  • flay 2.13.0
  • flog 4.6.6
  • ice_nine 0.11.2
  • jaro_winkler 1.5.5
  • launchy 2.4.3
  • minitest 5.18.0
  • parallel 1.23.0
  • parser 2.5.3.0
  • path_expander 1.1.1
  • public_suffix 5.0.1
  • rainbow 3.1.1
  • rake 12.3.3
  • reek 4.8.2
  • rubocop 0.68.1
  • ruby-progressbar 1.13.0
  • ruby_parser 3.20.1
  • rubycritic 3.5.2
  • sexp_processor 4.17.0
  • simplecov 0.22.0
  • simplecov-html 0.12.3
  • simplecov_json_formatter 0.1.4
  • sixarm_ruby_minitest_extensions 1.1.1
  • sixarm_ruby_zid 6.0.0
  • thread_safe 0.3.6
  • tty-which 0.3.0
  • unicode-display_width 1.5.0
  • virtus 1.0.5