All Projects → ad-si → ulid

ad-si / ulid

Licence: BSD-3-Clause license
Haskell implementation of ULIDs (Unique Lexicographically Sortable Identifiers)

Programming Languages

haskell
3896 projects

Labels

Projects that are alternatives of or similar to ulid

go-ulid
Universally Unique Lexicographically Sortable Identifier (ULID) in Go - Please use https://github.com/oklog/ulid
Stars: ✭ 31 (+40.91%)
Mutual labels:  uuid, ulid
python-ulid
ULID implementation for Python
Stars: ✭ 177 (+704.55%)
Mutual labels:  uuid, ulid
ulid-creator
A Java library for generating Universally Unique Lexicographically Sortable Identifiers (ULID)
Stars: ✭ 38 (+72.73%)
Mutual labels:  uuid, 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 (+36.36%)
Mutual labels:  uuid, ulid
ulid
Universally Unique Lexicographically Sortable Identifier (ULID) in Crystal
Stars: ✭ 28 (+27.27%)
Mutual labels:  uuid, ulid
rulid.rs
Rust Universally Unique Lexicographically Sortable Identifier
Stars: ✭ 40 (+81.82%)
Mutual labels:  uuid, ulid
Javascript
Universally Unique Lexicographically Sortable Identifier
Stars: ✭ 1,781 (+7995.45%)
Mutual labels:  uuid, ulid
Uuid
Erlang Native UUID Generation
Stars: ✭ 188 (+754.55%)
Mutual labels:  uuid
python-libuuid
Faster UUID generation using libuuid
Stars: ✭ 36 (+63.64%)
Mutual labels:  uuid
Msgphp
Reusable domain layers. Shipped with industry standard infrastructure.
Stars: ✭ 182 (+727.27%)
Mutual labels:  uuid
Uid Promise
Creates a cryptographically strong UID
Stars: ✭ 179 (+713.64%)
Mutual labels:  uuid
Python Wechat Itchat
微信机器人,基于Python itchat接口功能实例展示:01-itchat获取微信好友或者微信群分享文章、02-itchat获取微信公众号文章、03-itchat监听微信公众号发送的文章、04 itchat监听微信群或好友撤回的消息、05 itchat获得微信好友信息以及表图对比、06 python打印出微信被删除好友、07 itchat自动回复好友、08 itchat微信好友个性签名词云图、09 itchat微信好友性别比例、10 微信群或微信好友撤回消息拦截、11 itchat微信群或好友之间转发消息
Stars: ✭ 216 (+881.82%)
Mutual labels:  uuid
SierraChartZorroPlugin
A Zorro broker API plugin for Sierra Chart, written in Win32 C++.
Stars: ✭ 22 (+0%)
Mutual labels:  uuid
sno
Compact, sortable and fast unique IDs with embedded metadata.
Stars: ✭ 77 (+250%)
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 (+281.82%)
Mutual labels:  uuid
Nanoid
A tiny, secure, URL-friendly, unique string ID generator for Rust
Stars: ✭ 188 (+754.55%)
Mutual labels:  uuid
uuidgen-el
UUID generation implemented in elisp.
Stars: ✭ 44 (+100%)
Mutual labels:  uuid
Id Generator
生成带校验码的卡号、19位的Long ID、不大于22位的短UUID、短卡号、激活码、数字加密、付款码。分布式、基于内存、安全可靠、性能高。
Stars: ✭ 180 (+718.18%)
Mutual labels:  uuid
Ulid
Universally Unique Lexicographically Sortable Identifier implementation for Ruby
Stars: ✭ 253 (+1050%)
Mutual labels:  uuid
Uuid
Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
Stars: ✭ 3,237 (+14613.64%)
Mutual labels:  uuid

ULID Implementation in Haskell

Lexicographically sortable, 128-bit identifier with 48-bit timestamp and 80 random bits. Canonically encoded as a 26 character string, as opposed to the 36 character UUID.

Original implementation and spec: github.com/alizain/ulid

 01an4z07by   79ka1307sr9x4mv3

|----------| |----------------|
 Timestamp       Randomness
  48 bits         80 bits

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
  • UUID v1/v2 is impractical in many environments, as it requires access to a unique, stable MAC address
  • UUID v3/v5 requires a unique seed and produces randomly distributed IDs, which can cause fragmentation in many data structures
  • UUID v4 provides no other information than randomness, which can cause fragmentation in many data structures

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 Douglas Crockford's base 32 for better efficiency and readability (5 bits per character)
  • Case insensitive
  • No special characters (URL safe)

Usage

A simple usage example:

module Main where

import Data.ULID

main :: IO ()
main = do
  -- Derive a ULID using the current time and default random number generator
  ulid1 <- getULID
  print ulid1

  -- Derive a ULID using a specified time and default random number generator
  ulid2 <- getULIDTime 1469918176.385 -- POSIX Time, millisecond precision
  print ulid2

As per the spec, it is also possible to use a cryptographically-secure random number generator to contribute the randomness. However, the programmer must manage the generator on their own.

Example:

module Main where

import Data.ULID

import qualified Crypto.Random       as CR
import qualified Data.ULID.Random    as UR
import qualified Data.ULID.TimeStamp as TS

main :: IO ()
main = do
  -- This default instantiation may not be sufficiently secure.
  -- See the docs at
  -- hackage.haskell.org/package/crypto-api-0.13.2/docs/Crypto-Random.html
  g <- (CR.newGenIO :: IO CR.SystemRandom)

  -- Generate timestamp from current time
  t <- TS.getULIDTimeStamp

  let ulid3 = case UR.mkCryptoULIDRandom g of
          Left err        -> error $ show err
          -- use g2, …, to continue generating secure ULIDs
          Right (rnd, g2) -> ULID t rnd

  print ulid3

Test Suite

stack test

Performance

stack bench
Running 1 benchmarks...
Benchmark ulid-bench: RUNNING...
217,868 op/s generate
Benchmark ulid-bench: FINISH
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].