Tags - craterdog/go-component-framework GitHub Wiki

Overview

A tag string is a sequence of bytes encoded with the base 32 character set which excludes the vowels 'E', 'I', 'O', and 'U' to avoid confusion with '1' and '0' and avoid inadvertent offensive phrases being generated:

['0'..'9' 'A'..'D' 'F'..'H' 'J'..'N' 'P'..'T' 'V'..'Z']

Each tag string has the following string format:

$tag: '#' BASE32{13..}

The source of this format is Bali Document Notation™ (Bali) defined here.

There must be at least eight bytes (13 base 32 characters) in a tag to allow it to generate a cryptographically secure 64 bit hash code.

UML Diagram

A Quick Example

To whet your appetite, here is some short example code that demonstrates the use of tag strings.

package main

import (
	fmt "fmt"
	fra "github.com/craterdog/go-component-framework/v7"
)

func main() {
	// Create a new random tag string using the module level constructor shortcut.
	var tag = fra.TagWithSize(20) // 20 bytes -> 8 * 20 / 5 = 32 characters.
	fmt.Println("Tag:", tag)

	// Generate a hash code for the tag string.
	fmt.Println("Hash:", tag.GetHash())
}

Try it out in the Go Playground...