All Projects → phatboyg → Newid

phatboyg / Newid

Licence: apache-2.0
A sequential id generator that works across nodes with no collisions

Projects that are alternatives of or similar to Newid

secrets.clj
A library designed to generate cryptographically strong random numbers.
Stars: ✭ 64 (-74.9%)
Mutual labels:  uuid
vue-uuid
Add UUID to Vue instance.
Stars: ✭ 55 (-78.43%)
Mutual labels:  uuid
osma
An open source mobile agent for achieving SSI
Stars: ✭ 41 (-83.92%)
Mutual labels:  identity
uuix
A tiny (<1KB) and fast UUID (v4) generator for Crystal
Stars: ✭ 17 (-93.33%)
Mutual labels:  uuid
AspNetCore.Identity.Cassandra
Cassandra Storage Provider for ASP.NET Core Identity
Stars: ✭ 13 (-94.9%)
Mutual labels:  identity
twitch-chat-visualizer
A Node.js Project. Would you like to see your chat stream with a custom design? This is for you!
Stars: ✭ 14 (-94.51%)
Mutual labels:  uuid
Authl
A library for managing federated identity
Stars: ✭ 20 (-92.16%)
Mutual labels:  identity
Identity Address DB
(China) 1. MySQL 身份证 地区 数据库(包含已被合并的区县,详见README) 2. PHP 验证身份证号是否正确 3. 从身份证号中获取 性别 生日 年龄 出生地 等信息 4.路过留个star
Stars: ✭ 38 (-85.1%)
Mutual labels:  identity
Cosmos.Identity
A Cosmos storage provider for ASP.NET Core Identity.
Stars: ✭ 26 (-89.8%)
Mutual labels:  identity
syscoin
Syscoin is a crypto currency that is universally merge-mineable and offers a unique variety of services including decentralized identities, asset token issuance platform capabilities directly on the blockchain and trustless 0-counterparty interoptibility with the Ethereum blockchain
Stars: ✭ 152 (-40.39%)
Mutual labels:  identity
RepositoryHelpers
📦 Extensions for HttpClient and Custom Repository based on dapper
Stars: ✭ 22 (-91.37%)
Mutual labels:  identity
git-identity.el
Manage multiple Git identities from inside Emacs
Stars: ✭ 22 (-91.37%)
Mutual labels:  identity
PyVGGFace
VGG-Face CNN descriptor in PyTorch.
Stars: ✭ 21 (-91.76%)
Mutual labels:  identity
ulid-creator
A Java library for generating Universally Unique Lexicographically Sortable Identifiers (ULID)
Stars: ✭ 38 (-85.1%)
Mutual labels:  uuid
magic-admin-python
Magic admin Python SDK makes it easy to leverage Decentralized ID tokens to protect routes and restricted resources for your application.
Stars: ✭ 20 (-92.16%)
Mutual labels:  identity
user
A domain layer providing basic user management
Stars: ✭ 14 (-94.51%)
Mutual labels:  uuid
Identity.Firebase
ASP.NET Identity Firebase Provider
Stars: ✭ 23 (-90.98%)
Mutual labels:  identity
aragon-id
Aragon's simple identity solution to allow easy and secure ENS name assignments
Stars: ✭ 26 (-89.8%)
Mutual labels:  identity
shortuuid.rb
Convert UUIDs & numbers into space efficient and URL-safe Base62 strings, or any other alphabet.
Stars: ✭ 38 (-85.1%)
Mutual labels:  uuid
cyksuid
Fast Python implementation of KSUID (K-Sortable Globally Unique IDs) using Cython
Stars: ✭ 29 (-88.63%)
Mutual labels:  uuid

What is it

NewId can be used as an embedded unique ID generator that produces 128 bit (16 bytes) sequential IDs. It is inspired from snowflake and flake. Read on to learn more.

The Problem

A number of applications use unique identifiers to identify a data record. A common way for apps that use a relational database (RDBMS) is to delegate the generation of these IDs to the database - by means of a Identity column (MS-SQL) or similar. This approach is fine for a small app, but quickly becomes a bottleneck at web-scale. See this post from the blokes at twitter: https://blog.twitter.com/2010/announcing-snowflake Another use case is apps that use messaging to communicate between themselves - as is the case with a Microservices based architecture. These apps may require sequential unique IDs for messages.

An attempt at solutions

A trivial approach is to use GUIDs/UUIDs generated in applications. While that works, in most frameworks GUIDs are not sequential. This takes away the ability to sort records based on their unique ids.

The Solution

The Erlang library flake (https://github.com/boundary/flake) adopted an approach of generating 128-bit, k-ordered ids (read time-ordered lexically) using the machines MAC, timestamp and a per thread sequence number. These IDs are sequential and wouldn't collide in a cluster of nodes running applicaitons that use these as UUIDs.

Sample Code

NewId id = NewId.Next(); //produces an id like {11790000-cf25-b808-dc58-08d367322210}

// Supports operations similar to GUID
NewId id = NewId.Next().ToString("D").ToUpperInvariant();
// Produces 11790000-CF25-B808-2365-08D36732603A

// Start from an id
NewId id = new NewId("11790000-cf25-b808-dc58-08d367322210");

// Start with a byte-array
var bytes = new byte[] { 16, 23, 54, 74, 21, 14, 75, 32, 44, 41, 31, 10, 11, 12, 86, 42 };
NewId theId = new NewId(bytes);

When NOT to use sequential IDs

(Adapted from the flake readme) The generated ids are predictable by design. They should not be used in scenarios where unpredictability is a desired feature. These IDs should NOT be used for:

  • Generating passwords
  • Security tokens
  • Anything else you wouldn't want someone to be able to guess.

NewId generated ids expose the identity of the machine which generated the id (by way of its MAC address) and the time at which it did so. This could be a problem for some security-sensitive applications.

Don't do modulo 2 arithmetic on flake ids with the expectation of random distribution.

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