siphash

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKeySize = errors.New("siphash: key must be 16 bytes")
)

Functions

func Hash

func Hash(k0, k1 uint64, data []byte) uint64

Hash 计算 SipHash-2-4

func Sum64

func Sum64(key, data []byte) (uint64, error)

Sum64 使用指定密钥计算 SipHash

func Sum64FromInts

func Sum64FromInts(k0, k1 uint64, data []byte) uint64

Sum64FromInts 使用两个 uint64 作为密钥计算 SipHash

func SumHex

func SumHex(key, data []byte) (string, error)

SumHex 计算 SipHash 并返回十六进制字符串

func Verify

func Verify(key, data []byte, expected uint64) (bool, error)

Verify 验证 SipHash

Types

type SipHasher

type SipHasher struct {
	// contains filtered or unexported fields
}

SipHasher SipHash 哈希器

func NewSipHasher

func NewSipHasher(key []byte) (*SipHasher, error)

NewSipHasher 创建 SipHash 哈希器

func (*SipHasher) Sum

func (h *SipHasher) Sum(data []byte) []byte

Sum 返回哈希值的字节切片

func (*SipHasher) Sum64

func (h *SipHasher) Sum64(data []byte) uint64

Sum64 计算 SipHash-2-4 哈希值

func (*SipHasher) Sum64WithKey

func (h *SipHasher) Sum64WithKey(data, key []byte) (uint64, error)

Sum64WithKey 使用指定密钥计算 SipHash

func (*SipHasher) SumHex

func (h *SipHasher) SumHex(data []byte) string

SumHex 返回哈希值的十六进制字符串

func (*SipHasher) Type

func (h *SipHasher) Type() common.IntegrityType

Type 返回校验类型

Jump to

Keyboard shortcuts

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