uid

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UID

type UID interface {
	// Hex 返回十六进制表示
	Hex() string
	// Base32 返回 base32 编码表示
	Base32() string
	// String 返回字符串表示
	// 格式为 `{hex}({base32})`
	String() string
}

UID 唯一 ID

func DecodeUID128FromBase32

func DecodeUID128FromBase32(in string) (UID, error)

DecodeUID128FromBase32 从 base32 形式解码 128 位 UID 输入 26 个字符

func DecodeUID128FromHex

func DecodeUID128FromHex(in string) (UID, error)

DecodeUID128FromHex 从十六进制形式解码 128 位 UID 输入 32 个字符

func NewUID128

func NewUID128() UID

NewUID128 生成一个随机的 128 位 UID

func NewUID128FromHash

func NewUID128FromHash(data []byte, algorithm func() hash.Hash) UID

NewUID128FromHash 通过指定哈希算法生成一个 128 位 UID 如果哈希算法输出大于 128 位,则取高 128 位,不足 128 位则以 0 补足

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL