acid

package module
v0.0.0-...-5644093 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Overview

ACID is an UUID like value created from a data hash (SHA3) salted with 48 random bits.

Aim was to create a rather unique salted value in a common format, from a data source (string, file, etc.) that was computed by a cryptographic hash function and thus not easily retraceable and equipped with a random component that has the effect that two of the same do not necessarily result in the same value. But the identical random component must make it's result deterministic. Great for eg. User-ID build from simple person attributes like given name and surname.

ACID is similar to UUIDv5 since both are hashed values as SHA3-512 and respectively SHA1 for UUIDv5. A UUIDv7 inspiration is the use of 48 random bits, that are included as a salt and are visibly represented in the last 6 bytes of the value.

Example
package main

import (
	"fmt"
	"log"

	"catinello.eu/acid"
)

func main() {
	a, err := acid.New([]byte("User1"))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(a)
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(a ACID, b ACID) bool

Equal compares if a is equal b.

Types

type ACID

type ACID [size]byte

ACID is a 128 bit (16 byte) Universal Unique IDentifier.

var (
	// 00000000-0000-0000-0000-000000000000
	Nil ACID = [size]byte{}
	// FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
	Max ACID = [size]byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
)

func Create

func Create(random, data []byte) (ACID, error)

Create builds a ACID from the given values to be deterministic.

func Must

func Must(data []byte) ACID

Must create an ACID from data.

func MustParse

func MustParse(acid string) ACID

MustParse takes an ACID as string and returns an ACID type or panic.

func New

func New(data []byte) (ACID, error)

New create an ACID from data.

func Parse

func Parse(acid string) (ACID, error)

Parse takes an ACID as string and returns an ACID or error.

func (ACID) Compare

func (acid ACID) Compare(other ACID) bool

Compare this with other ACID.

func (ACID) Short

func (acid ACID) Short(rev bool) string

Short returns an abbreviation of the ACID value.

func (ACID) String

func (acid ACID) String() string

String returns a hex-encoded value of that ACID.

Format: xxxxxxxx-xxxx-axxx-xxxx-RRRRRRRRRRRR

Directories

Path Synopsis
cmd
acid module

Jump to

Keyboard shortcuts

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