hash

package
v0.0.0-...-2514748 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package hash implements the digest and digest_xof function families (Families 1 and 2). Supports SHA-256/384/512, SHA3-256/384/512, SHAKE128/256.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstantTimeCompare

func ConstantTimeCompare(a, b []byte) bool

ConstantTimeCompare compares two byte slices in constant time.

func Digest

func Digest(data []byte, algorithm string) ([]byte, error)

Digest computes the hash digest of data using the specified algorithm. Family 1: digest(data []byte, algorithm string) ([]byte, error)

func DigestOutputLength

func DigestOutputLength(algo DigestAlgorithm) (int, error)

DigestOutputLength returns the output length in bytes for a fixed-output algorithm.

func DigestXOF

func DigestXOF(data []byte, algorithm string, outputLength uint32) ([]byte, error)

DigestXOF computes the extendable-output hash (SHAKE) of data with variable output length. Family 2: digest_xof(data []byte, algorithm string, output_length uint32) ([]byte, error)

func ListSupportedDigests

func ListSupportedDigests() []string

ListSupportedDigests returns all supported digest algorithms.

Types

type DigestAlgorithm

type DigestAlgorithm string

DigestAlgorithm represents a hash algorithm identifier.

const (
	AlgorithmSHA256   DigestAlgorithm = "SHA-256"
	AlgorithmSHA384   DigestAlgorithm = "SHA-384"
	AlgorithmSHA512   DigestAlgorithm = "SHA-512"
	AlgorithmSHA3_256 DigestAlgorithm = "SHA3-256"
	AlgorithmSHA3_384 DigestAlgorithm = "SHA3-384"
	AlgorithmSHA3_512 DigestAlgorithm = "SHA3-512"
	AlgorithmSHAKE128 DigestAlgorithm = "SHAKE128"
	AlgorithmSHAKE256 DigestAlgorithm = "SHAKE256"
)

type DigestAlgorithmInfo

type DigestAlgorithmInfo struct {
	Name         string
	OutputLength int
	Standard     string
	Mode         []string
}

DigestAlgorithmInfo holds metadata about a digest algorithm.

func GetDigestAlgorithmInfo

func GetDigestAlgorithmInfo(algorithm string) (*DigestAlgorithmInfo, error)

GetDigestAlgorithmInfo returns metadata for the given algorithm.

Jump to

Keyboard shortcuts

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