Documentation
¶
Overview ¶
Package hash provides SHA-256 and xxHash helpers for message and content hashing.
Index ¶
- func HashBytes(b []byte) string
- func HashSHA256(data []byte) string
- func HashSHA256String(data []byte) [32]byte
- func HashSHA512(data []byte) string
- func HashXXHash(data []byte) uint64
- func MsgHash(topic string, message []byte) string
- func MsgHashWithTimestamp(topic string, message []byte, timestamp int64) string
- func WriteBool(h stdhash.Hash, v bool)
- func WriteFloat32(h stdhash.Hash, v float32)
- func WriteInt64(h stdhash.Hash, v int64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashBytes ¶
HashBytes returns a SHA256 hash of the given bytes as a hex string. Returns empty string if input is empty.
func HashSHA256 ¶
HashSHA256 computes SHA-256 hash returns hex-encoded string
func HashSHA256String ¶
HashSHA256String computes the SHA-256 hash, returns the raw 32-byte array
func HashSHA512 ¶
HashSHA512 computes SHA-512 hash, returns hex-encoded string
func HashXXHash ¶
HashXXHash computes the XXHash, fast, non-cryptographic
func MsgHash ¶
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 ¶
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 ¶
WriteBool writes a boolean value to the hash in a deterministic format (1 for true, 0 for false).
func WriteFloat32 ¶
WriteFloat32 writes a float32 value to the hash by converting it to its IEEE 754 binary representation.
func WriteInt64 ¶
WriteInt64 writes an int64 value to the hash in little-endian format.
Types ¶
This section is empty.