Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

valid is a generator of random IDs. It is sortable and can be validated using a checksum.

License

NotificationsYou must be signed in to change notification settings

juntaki/valid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go ReferenceGoCover

valid is a library for generating random ID, with the default configuration as follows

  • 5 bytes timestamp
  • 14 bytes of random bytes
  • 1 byte checksum

Features:

  • Cryptographically secure (use of crypto/rand)
  • Lexicographically sortable
  • Allows validation of ID
  • Word safe and URL safe characters
  • Embedded time with millisecond precision

In addition, most of the features can be changed by configuration.

NameSecure Random Bit SizeString ID SizeSortableChecksum
google/uuid122 bits36 charsnono
oklog/ulid80 bits (user defined source)26 charsyesno
rs/xidn/a (not cryptographically secure)20 charsyesno
valid (default)112 bits32 charsyesyes
valid (configurable)anydepends on configyes / noyes / no

Install

go get github.com/juntaki/valid

Usage

id:=valid.Generate()fmt.Println(id,len(id),valid.IsValid(id),valid.Timestamp(id))// Output: 2X9P75FX2pJqCcHRVWV2862JW6XhFr6x 32 true 2021-09-08 23:59:17.339250688 +0900 JST

About

valid is a generator of random IDs. It is sortable and can be validated using a checksum.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp