Documentation
¶
Overview ¶
Package hashing exposes the full set of cryptographic hash algorithms the Truestamp backend accepts for a claim's `hash_type` field. The goal is feature-parity with sha256sum / shasum / openssl dgst so users do not have to shell out to those tools for a one-off digest.
Algorithm names match the string forms in internal/tscrypto/hash.go's hashTypes registry, with common aliases (sha3-256/sha3_256, blake2b vs blake2b-512) accepted case-insensitively. Output formatting is byte-identical to GNU coreutils' sha256sum (text and binary modes, with the standard `\` escaping for filenames containing `\` or `\n`) and to `shasum --tag` / BSD md5(1)'s tagged form.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compute ¶
Compute streams r through alg's hasher and returns the digest bytes and the total byte count consumed. Never buffers the whole input. The context is checked once before starting; I/O errors are wrapped.
func FormatBSD ¶
FormatBSD produces output byte-identical to `shasum --tag` / BSD md5(1)'s tagged form:
"<NAME> (<filename>) = <hex>\n"
func FormatGNU ¶
FormatGNU produces output byte-identical to GNU coreutils' sha256sum (and friends):
text mode: "<hex> <filename>\n" binary mode: "<hex> *<filename>\n"
Filenames containing '\' or '\n' get GNU's escape treatment: the line is prefixed with '\' and the problematic bytes are escaped as "\\" and "\n". Callers on filesystems that cannot produce such names still get the unescaped form.
Types ¶
type Algorithm ¶
type Algorithm struct {
Name string // canonical name (kebab-case)
Aliases []string
Size int // digest length in bytes
Legacy bool // true for broken algorithms (MD5, SHA-1)
BSDName string // upper-case name used in shasum --tag / BSD output
New func() hash.Hash // constructor; never returns nil
}
Algorithm describes a single supported hash algorithm.
func Algorithms ¶
func Algorithms() []Algorithm
Algorithms returns a copy of the registry, ordered for display.