Documentation
¶
Overview ¶
Package hash provides stable content hash helpers for reliquary primitives. Callers own byte canonicalization and downstream invalidation policy.
Package hash provides stable content hash helpers for reliquary primitives.
Index ¶
Examples ¶
Constants ¶
const (
// AlgorithmSHA256 is the canonical algorithm name used by reliquary metadata.
AlgorithmSHA256 = "sha256"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Digest ¶
Digest identifies content by algorithm and hex-encoded value.
func HashIdentity ¶
func HashIdentity(parts ...IdentityPart) Digest
HashIdentity returns a stable digest for ordered transform identity parts. Reordering parts changes the digest. Zero-value parts and empty fields are omitted deterministically.
Example ¶
package main
import (
"fmt"
"github.com/dotcommander/reliquary/internal/hash"
)
func main() {
digest := hash.HashIdentity(
hash.IdentityPart{Kind: "source", InputHash: "source-sha"},
hash.IdentityPart{Kind: "chunker", Version: "v1", ConfigHash: "chunk-cfg"},
)
fmt.Println(digest.Algorithm, digest.String() != "")
}
Output: sha256 true
func SHA256Reader ¶
SHA256Reader streams r into a SHA-256 digest.
func SHA256String ¶
SHA256String returns a SHA-256 digest for s.
Example ¶
package main
import (
"fmt"
"github.com/dotcommander/reliquary/internal/hash"
)
func main() {
digest := hash.SHA256String("body")
fmt.Println(digest.Algorithm, digest.String() != "")
}
Output: sha256 true
type Identity ¶
type Identity []IdentityPart
Identity is an ordered list of transform identity parts.
type IdentityPart ¶
type IdentityPart struct {
Kind string
ID string
Version string
ConfigHash string
InputHash string
Value string
Digest Digest
}
IdentityPart names one ordered input to a derived artifact identity. Empty fields are omitted from the hash encoding, so callers can fill only the dimensions they own.