Documentation
¶
Overview ¶
Package types implements the functions, types, and interfaces for the module.
Index ¶
- func TypeHash(subAlg string) (stdhash.Hash, error)
- type AlgorithmResolver
- type Config
- type HashParts
- func (h *HashParts) String() string
- func (h *HashParts) WithAlgorithm(algorithm string) *HashParts
- func (h *HashParts) WithHash(hash []byte) *HashParts
- func (h *HashParts) WithHashSalt(hash []byte, salt []byte) *HashParts
- func (h *HashParts) WithParams(params map[string]string) *HashParts
- func (h *HashParts) WithSalt(salt []byte) *HashParts
- func (h *HashParts) WithVersion(version string) *HashParts
- type Option
- type ParamStringer
- type Params
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlgorithmResolver ¶ added in v0.3.18
AlgorithmResolver defines an interface for resolving and normalizing algorithm types.
type Config ¶
type Config struct {
SaltLength int `env:"HASH_SALTLENGTH"`
ParamConfig string `env:"HASH_PARAM_CONFIG"`
}
Config represents the configuration for hash algorithms
type HashParts ¶
type HashParts struct {
Algorithm string
Version string
Params map[string]string
Hash []byte
Salt []byte
}
HashParts represents the parts of a hash
func NewHashParts ¶ added in v0.3.18
func NewHashPartsFull ¶ added in v0.3.18
func NewHashPartsWithHashSalt ¶ added in v0.3.18
func (*HashParts) WithAlgorithm ¶ added in v0.3.18
func (*HashParts) WithHashSalt ¶ added in v0.3.18
func (*HashParts) WithParams ¶ added in v0.3.18
func (*HashParts) WithVersion ¶ added in v0.3.18
type Option ¶
type Option func(*Config)
Option is a function that modifies a Config
func WithParamConfig ¶ added in v0.2.17
func WithParams ¶
func WithParams(params ParamStringer) Option
func WithParamsString ¶
type ParamStringer ¶ added in v0.3.18
type ParamStringer interface {
String() string
}
ParamStringer defines an interface for types that can be converted to a string representation of parameters.
type Type ¶
type Type struct {
// Name is the main algorithm's name, e.g., "hmac", "pbkdf2", "sha256".
// This is the key field for logical dispatch.
Name string
// Underlying is the full string representation of the underlying hash algorithm.
// For simple hashes, this field is empty.
// For composite hashes, it specifies the hash function to be used,
// e.g., "sha256" for "hmac-sha256", or "sha3-512" for "pbkdf2-sha3-512".
Underlying string
}
Type represents a structured hash algorithm definition. It separates the main algorithm from its underlying hash function, allowing for clear and extensible handling of composite algorithms like HMAC and PBKDF2.
func NewType ¶ added in v0.3.18
NewType creates a new Type instance with the specified name and underlying hash.