All Projects → SuperPaintman → ulid

SuperPaintman / ulid

Licence: MIT license
Universally Unique Lexicographically Sortable Identifier (ULID) in Crystal

Programming Languages

crystal
512 projects

Labels

Projects that are alternatives of or similar to ulid

uuid-generator-plugin
An IntelliJ Idea plugin to generate UUID (Universally Unique Identifier), ULID (Universally Unique Lexicographically Sortable Identifier) and CUID (Collision Resistant Unique Identifier)
Stars: ✭ 30 (+7.14%)
Mutual labels:  uuid, ulid
python-ulid
ULID implementation for Python
Stars: ✭ 177 (+532.14%)
Mutual labels:  uuid, ulid
rulid.rs
Rust Universally Unique Lexicographically Sortable Identifier
Stars: ✭ 40 (+42.86%)
Mutual labels:  uuid, ulid
ulid
Haskell implementation of ULIDs (Unique Lexicographically Sortable Identifiers)
Stars: ✭ 22 (-21.43%)
Mutual labels:  uuid, ulid
go-ulid
Universally Unique Lexicographically Sortable Identifier (ULID) in Go - Please use https://github.com/oklog/ulid
Stars: ✭ 31 (+10.71%)
Mutual labels:  uuid, ulid
ulid-creator
A Java library for generating Universally Unique Lexicographically Sortable Identifiers (ULID)
Stars: ✭ 38 (+35.71%)
Mutual labels:  uuid, ulid
Javascript
Universally Unique Lexicographically Sortable Identifier
Stars: ✭ 1,781 (+6260.71%)
Mutual labels:  uuid, ulid
Icicle
A distributed, k-sortable unique ID generation system using Redis and Lua.
Stars: ✭ 159 (+467.86%)
Mutual labels:  uuid
Ulid
Universally Unique Lexicographically Sortable Identifier (ULID) in Python 3
Stars: ✭ 216 (+671.43%)
Mutual labels:  uuid
Uuid
Kotlin Multiplatform UUID
Stars: ✭ 146 (+421.43%)
Mutual labels:  uuid
Laravel Uuid
Laravel package to generate and to validate a UUID according to the RFC 4122 standard. Only support for version 1, 3, 4 and 5 UUID are built-in.
Stars: ✭ 1,717 (+6032.14%)
Mutual labels:  uuid
UUIDNext
A fast and modern .NET library to generate UUID/GUID that are either sequential and database friendly (versions 7), name based (versions 5) or random (version 4).
Stars: ✭ 84 (+200%)
Mutual labels:  uuid
Uuid
Erlang Native UUID Generation
Stars: ✭ 188 (+571.43%)
Mutual labels:  uuid
Lua Resty Jit Uuid
Fast and dependency-free UUID library for LuaJIT/ngx_lua
Stars: ✭ 169 (+503.57%)
Mutual labels:  uuid
Ksuid
K-Sortable Globally Unique IDs
Stars: ✭ 3,202 (+11335.71%)
Mutual labels:  uuid
Zkudid
Generate and save permanent UDID with IDFV and keychain in iOS device.
Stars: ✭ 159 (+467.86%)
Mutual labels:  uuid
yii2-uuid
UUID Helper and validator for Yii 2
Stars: ✭ 33 (+17.86%)
Mutual labels:  uuid
Uuid
A PHP library for generating universally unique identifiers (UUIDs).
Stars: ✭ 11,475 (+40882.14%)
Mutual labels:  uuid
Nanoid
A tiny, secure, URL-friendly, unique string ID generator for Rust
Stars: ✭ 188 (+571.43%)
Mutual labels:  uuid
Ulid
Universally Unique Lexicographically Sortable Identifier implementation for Ruby
Stars: ✭ 253 (+803.57%)
Mutual labels:  uuid

ULID

Linux Build Shards version

A Crystal port of alizain/ulid.

Logo

Universally Unique Lexicographically Sortable Identifier

UUID can be suboptimal for many uses-cases because:

  • It isn't the most character efficient way of encoding 128 bits of randomness
  • The string format itself is apparently based on the original MAC & time version (UUIDv1 from Wikipedia)
  • It provides no other information than randomness

Instead, herein is proposed ULID:

  • 128-bit compatibility with UUID
  • 1.21e+24 unique ULIDs per millisecond
  • Lexicographically sortable!
  • Canonically encoded as a 26 character string, as opposed to the 36 character UUID
  • Uses Crockford's base32 for better efficiency and readability (5 bits per character)
  • Case insensitive
  • No special characters (URL safe)

Installation

Add this to your application's shard.yml:

dependencies:
  ulid:
    github: SuperPaintman/ulid

Usage

require "ulid"

ULID.generate
# => "01B3EAF48P97R8MP9WS6MHDTZ3"

Seed Time

You can also input a seed time which will consistently give you the same string for the time component. This is useful for migrating to ulid.

ULID.generate Time.now + 5.second
# => "01ARYZ6S41TSV4RRFFQ69G5FAV"

Specification

Below is the current specification of ULID as implemented in this repository.

Components

Timestamp

  • 48 bit integer
  • UNIX-time in milliseconds
  • Won't run out of space till the year 10895 AD.

Randomness

  • 80 bits
  • Cryptographically secure source of randomness, if possible

Sorting

The left-most character must be sorted first, and the right-most character sorted last (lexical order). The default ASCII character set must be used. Within the same millisecond, sort order is not guaranteed

Encoding

Crockford's Base32 is used as shown. This alphabet excludes the letters I, L, O, and U to avoid confusion and abuse.

0123456789ABCDEFGHJKMNPQRSTVWXYZ

Binary Layout and Byte Order

The components are encoded as 16 octets. Each component is encoded with the Most Significant Byte first (network byte order).

0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      32_bit_uint_time_low                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     16_bit_uint_time_high     |       16_bit_uint_random      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       32_bit_uint_random                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       32_bit_uint_random                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

String Representation

 01AN4Z07BY      79KA1307SR9X4MV3
|----------|    |----------------|
 Timestamp           Entropy
  10 chars           16 chars
   48bits             80bits
   base32             base32

Test

crystal spec

Contributing

  1. Fork it (https://github.com/SuperPaintman/ulid/fork)
  2. Create your feature branch (git checkout -b feature/<feature_name>)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin feature/<feature_name>)
  5. Create a new Pull Request

Contributors


API

Docs


Changelog

Changelog


License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].