Documentation
¶
Overview ¶
Package anyhash provides a unified interface for hash algorithms selected by name.
Unlike Go's standard crypto packages, anyhash lets you specify the algorithm as a string and provides a Clone method to duplicate hash state at any point.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalPHP ¶ added in v0.1.1
MarshalPHP serializes a Hash's internal state into PHP-compatible components. Returns the PHP algorithm name, state as int32 values, and the buffer.
Types ¶
type Hash ¶
type Hash interface {
hash.Hash
// Clone returns an independent copy of the hash in its current state.
Clone() Hash
}
Hash extends hash.Hash with the ability to clone the current state.
func New ¶
New creates a new Hash for the named algorithm. Algorithm names are case-insensitive and hyphens are ignored, so "SHA-256", "sha256", and "SHA256" all work.
type PHPMarshaler ¶ added in v0.1.1
type PHPMarshaler interface {
// PHPAlgo returns the PHP-compatible algorithm name (e.g. "sha256", "tiger192,3").
PHPAlgo() string
// MarshalPHP returns the hash state as PHP-compatible int32 values and a buffer.
MarshalPHP() ([]int32, []byte)
// UnmarshalPHP restores the hash state from PHP-compatible int32 values and a buffer.
UnmarshalPHP(state []int32, buf []byte) error
}
PHPMarshaler is implemented by hashes that support PHP-compatible state serialization. The state is represented as signed int32 values (matching PHP's integer representation) plus a raw buffer.