Documentation
¶
Overview ¶
Package scheme implements the functions, types, and interfaces for the module.
Package scheme defines the core interfaces for hash algorithm implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlgorithmConfig ¶
AlgorithmConfig defines a function that returns a Config object for a specific algorithm.
func (AlgorithmConfig) Config ¶
func (c AlgorithmConfig) Config() *types.Config
Config implements the AlgorithmConfig interface.
type AlgorithmCreator ¶
AlgorithmCreator is a function that creates an instance of Scheme given its type and configuration.
type AlgorithmResolver ¶
func (AlgorithmResolver) ResolveSpec ¶
type Factory ¶
type Factory interface {
// Config returns the default configuration for this factory.
Config() *types.Config
// Create uses a unified Config object to create a Scheme instance.
Create(spec types.Spec, cfg *types.Config) (Scheme, error)
// ResolveSpec resolves a spec string to a types.Spec object using the internal alias map.
ResolveSpec(types.Spec) (types.Spec, error)
}
Factory defines the contract for creating Scheme instances. This is the sole entry point for creating any Scheme, used by both NewCrypto and Verify.
type Scheme ¶
type Scheme interface {
// Spec returns the unique, structured specification of this scheme.
Spec() types.Spec
// Hash generates a hash for the given password, creating a new salt internally.
Hash(password string) (*types.HashParts, error)
// HashWithSalt generates a hash for the given password with a specified salt.
HashWithSalt(password string, salt []byte) (*types.HashParts, error)
// Verify checks if the given password matches the information stored in HashParts.
// The implementation should rely on the configuration of the Scheme instance it is called on,
// which is expected to be created by the factory with the correct parameters from the original hash.
Verify(parts *types.HashParts, password string) error
}
Scheme defines the interface for a specific, configured cryptographic hash algorithm. An instance of a Scheme is expected to be immutable once created.