hash

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package hash provides SHA-256 and xxHash helpers for message and content hashing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashBytes

func HashBytes(b []byte) string

HashBytes returns a SHA256 hash of the given bytes as a hex string. Returns empty string if input is empty.

func HashSHA256

func HashSHA256(data []byte) string

HashSHA256 computes SHA-256 hash returns hex-encoded string

func HashSHA256String

func HashSHA256String(data []byte) [32]byte

HashSHA256String computes the SHA-256 hash, returns the raw 32-byte array

func HashSHA512

func HashSHA512(data []byte) string

HashSHA512 computes SHA-512 hash, returns hex-encoded string

func HashXXHash

func HashXXHash(data []byte) uint64

HashXXHash computes the XXHash, fast, non-cryptographic

func MsgHash

func MsgHash(topic string, message []byte) string

MsgHash returns a deterministic hash of topic + message for message identity (e.g. deduplication). For time-scoped identity (e.g. same message at different times), use MsgHashWithTimestamp.

func MsgHashWithTimestamp

func MsgHashWithTimestamp(topic string, message []byte, timestamp int64) string

MsgHashWithTimestamp returns a hash of topic + message + timestamp for time-scoped identity (e.g. duplicate detection when the same content can be sent at different times). For content-only identity, use MsgHash.

func WriteBool

func WriteBool(h stdhash.Hash, v bool)

WriteBool writes a boolean value to the hash in a deterministic format (1 for true, 0 for false).

func WriteFloat32

func WriteFloat32(h stdhash.Hash, v float32)

WriteFloat32 writes a float32 value to the hash by converting it to its IEEE 754 binary representation.

func WriteInt64

func WriteInt64(h stdhash.Hash, v int64)

WriteInt64 writes an int64 value to the hash in little-endian format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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