All Projects → lithammer → Shortuuid

lithammer / Shortuuid

Licence: mit
🍄 A generator library for concise, unambiguous and URL-safe UUIDs

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Shortuuid

Butterfly
分布式ID生成器框架:超高性能的发号器框架。通过引入多种新的方案,彻底解决雪花算法的时间回拨等问题,并将雪花算法原生QPS提高最少十几~二十倍
Stars: ✭ 111 (-81.59%)
Mutual labels:  uuid
cyksuid
Fast Python implementation of KSUID (K-Sortable Globally Unique IDs) using Cython
Stars: ✭ 29 (-95.19%)
Mutual labels:  uuid
Go Nanoid
Golang random IDs generator.
Stars: ✭ 373 (-38.14%)
Mutual labels:  uuid
user
A domain layer providing basic user management
Stars: ✭ 14 (-97.68%)
Mutual labels:  uuid
vue-uuid
Add UUID to Vue instance.
Stars: ✭ 55 (-90.88%)
Mutual labels:  uuid
Newid
A sequential id generator that works across nodes with no collisions
Stars: ✭ 255 (-57.71%)
Mutual labels:  uuid
php-tools
Some code snippets that are often used in PHP
Stars: ✭ 25 (-95.85%)
Mutual labels:  uuid
Uuid
Generate and parse UUIDs.
Stars: ✭ 457 (-24.21%)
Mutual labels:  uuid
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 (-97.68%)
Mutual labels:  uuid
Android cn oaid
适用于国内各大Android手机厂商的开放匿名设备标识(OAID)解决方案,可替代移动安全联盟提供的 SDK 闭源方案(miit_mdid_xxx.aar)。
Stars: ✭ 370 (-38.64%)
Mutual labels:  uuid
secrets.clj
A library designed to generate cryptographically strong random numbers.
Stars: ✭ 64 (-89.39%)
Mutual labels:  uuid
uuix
A tiny (<1KB) and fast UUID (v4) generator for Crystal
Stars: ✭ 17 (-97.18%)
Mutual labels:  uuid
Xyuuid
iOS14 UUID KeyChain DeviceInfo IDFA UDID
Stars: ✭ 301 (-50.08%)
Mutual labels:  uuid
micell
A collection of functions for front-end development
Stars: ✭ 16 (-97.35%)
Mutual labels:  uuid
Laravel Eloquent Uuid
A simple drop-in solution for providing UUID support for the IDs of your Eloquent models.
Stars: ✭ 388 (-35.66%)
Mutual labels:  uuid
ksuid-go
K-Sortable globally Unique ID
Stars: ✭ 15 (-97.51%)
Mutual labels:  uuid
shortuuid.rb
Convert UUIDs & numbers into space efficient and URL-safe Base62 strings, or any other alphabet.
Stars: ✭ 38 (-93.7%)
Mutual labels:  uuid
Laravel Binary Uuid
Optimised binary UUIDs in Laravel
Stars: ✭ 523 (-13.27%)
Mutual labels:  uuid
Go.uuid
UUID package for Go
Stars: ✭ 4,427 (+634.16%)
Mutual labels:  uuid
Uniuri
Go package uniuri generates random strings good for use in URIs to identify unique objects.
Stars: ✭ 336 (-44.28%)
Mutual labels:  uuid

shortuuid

Build Status Godoc

A Go library that generates concise, unambiguous, URL-safe UUIDs. Based on and compatible with the Python library shortuuid.

Often, one needs to use non-sequential IDs in places where users will see them, but the IDs must be as concise and easy to use as possible. shortuuid solves this problem by generating UUIDs using google/uuid and then translating them to base57 using lowercase and uppercase letters and digits, and removing similar-looking characters such as l, 1, I, O and 0.

Usage

package main

import (
    "fmt"

    "github.com/lithammer/shortuuid/v3"
)

func main() {
    u := shortuuid.New() // Cekw67uyMpBGZLRP2HFVbe
}

To use UUID v5 (instead of the default v4), use NewWithNamespace(name string) instead of New().

shortuuid.NewWithNamespace("http://example.com")

It's possible to use a custom alphabet as well, though it has to be 57 characters long.

alphabet := "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxy="
shortuuid.NewWithAlphabet(alphabet) // u=BFWRLr5dXbeWf==iasZi

Bring your own encoder! For example, base58 is popular among bitcoin.

package main

import (
    "fmt"
    "github.com/btcsuite/btcutil/base58"
    "github.com/lithammer/shortuuid/v3"
    "github.com/satori/go.uuid"
)

type base58Encoder struct {}

func (enc base58Encoder) Encode(u uuid.UUID) string {
    return base58.Encode(u.Bytes())
}

func (enc base58Encoder) Decode(s string) (uuid.UUID, error) {
    return uuid.FromBytes(base58.Decode(s))
}

func main() {
    enc := base58Encoder{}
    fmt.Println(shortuuid.NewWithEncoder(enc)) // 6R7VqaQHbzC1xwA5UueGe6
}

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