hash

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentHash

func ContentHash(content []byte, referenceHash string) string

ContentHash hashes content using the algorithm implied by referenceHash length. 64-char reference = SHA3-256, otherwise SHA1. referenceHash must not be empty.

func HashSize

func HashSize(hashType string) int

func IsValidHash

func IsValidHash(h string) bool

func SHA1

func SHA1(data []byte) string
Example
package main

import (
	"fmt"

	"github.com/danmestas/libfossil/internal/hash"
)

func main() {
	uuid := hash.SHA1([]byte("hello"))
	fmt.Println(uuid)
	fmt.Println(hash.IsValidHash(uuid))
}
Output:
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
true

func SHA3

func SHA3(data []byte) string
Example
package main

import (
	"fmt"

	"github.com/danmestas/libfossil/internal/hash"
)

func main() {
	uuid := hash.SHA3([]byte("hello"))
	fmt.Println(len(uuid)) // 64 hex chars = SHA3-256
	fmt.Println(hash.IsValidHash(uuid))
}
Output:
64
true

Types

This section is empty.

Jump to

Keyboard shortcuts

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