Documentation
¶
Overview ¶
Package hash implements the functions, types, and interfaces for the module.
Package hash provides the hash functions ¶
Package hash implements the functions, types, and interfaces for the module.
Package hash implements the functions, types, and interfaces for the module.
Package hash implements the functions, types, and interfaces for the module.
Index ¶
- func AvailableAlgorithms() []string
- func ConfigFromHashParts(parts *types.HashParts) *types.Config
- func Generate(password string) (string, error)
- func GenerateWithSalt(password string, salt []byte) (string, error)
- func Register(factory scheme.Factory, canonicalSpec types.Spec, aliases ...string)
- func UseCrypto(algName string, opts ...Option) error
- func Verify(hashed, password string) error
- type Crypto
- type Factory
- func (f *Factory) AvailableAlgorithms() []string
- func (f *Factory) Create(spec types.Spec, cfg *types.Config) (scheme.Scheme, error)
- func (f *Factory) GetConfig(name string) *types.Config
- func (f *Factory) GetFactory(name string) (scheme.Factory, bool)
- func (f *Factory) GetSpec(specStr string) (types.Spec, bool)
- func (f *Factory) Register(factory scheme.Factory, canonicalSpec types.Spec, aliases ...string)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AvailableAlgorithms ¶ added in v0.3.18
func AvailableAlgorithms() []string
AvailableAlgorithms returns a list of all registered hash algorithm aliases from the default factory.
func ConfigFromHashParts ¶ added in v1.1.0
ConfigFromHashParts creates a Config from a HashParts object.
func GenerateWithSalt ¶
GenerateWithSalt is a convenience function that uses the active global crypto instance.
func Register ¶ added in v1.1.0
Register is a convenience function that registers a factory to the default global factory.
Types ¶
type Crypto ¶
type Crypto interface {
Spec() types.Spec
Hash(password string) (string, error)
HashWithSalt(password string, salt []byte) (string, error)
Verify(hashed, password string) error
}
Crypto defines the interface for a cryptographic instance. It can be used to hash new passwords with its configured scheme and verify any hash.
func NewCrypto ¶
NewCrypto is the primary convenience function for creating a Crypto instance. It uses the default global factory.
func NewCryptoWithFactory ¶ added in v1.1.0
NewCryptoWithFactory creates a Crypto instance using a specific, provided factory. This is useful for testing or creating isolated instances with different configurations.
type Factory ¶ added in v1.1.0
type Factory struct {
// contains filtered or unexported fields
}
Factory holds the registration of all scheme factories and spec mappings.
func NewFactory ¶ added in v1.1.0
func NewFactory() *Factory
NewFactory creates a new, empty factory.
func (*Factory) AvailableAlgorithms ¶ added in v1.1.0
AvailableAlgorithms returns a list of all registered hash algorithm aliases.
func (*Factory) Create ¶ added in v1.1.0
Create uses the registered providers to create a new Scheme instance.
func (*Factory) GetConfig ¶ added in v1.1.0
GetConfig returns the default configuration for a given algorithm module.
func (*Factory) GetFactory ¶ added in v1.1.0
type Option ¶ added in v1.1.0
Option is a function that modifies a Config
func WithHashParts ¶ added in v1.1.0
WithHashParts sets the salt length and parameters from a HashParts object.
func WithParamString ¶ added in v1.1.0
WithParamString sets the parameters for the hash algorithm using a type that implements fmt.Stringer.
func WithParams ¶ added in v1.1.0
WithParams sets the parameters for the hash algorithm directly from a map[string]string. This is the preferred way to set algorithm-specific parameters when they are already in map format.
func WithSaltLength ¶ added in v1.1.0
WithSaltLength sets the salt length
Directories
¶
| Path | Synopsis |
|---|---|
|
algorithms
|
|
|
argon2
Package argon2 implements the functions, types, and interfaces for the module.
|
Package argon2 implements the functions, types, and interfaces for the module. |
|
blake2
Package blake2 implements the functions, types, and interfaces for the module.
|
Package blake2 implements the functions, types, and interfaces for the module. |
|
crc
Package crc implements the functions, types, and interfaces for the module.
|
Package crc implements the functions, types, and interfaces for the module. |
|
hmac
Package hmac implements the functions, types, and interfaces for the module.
|
Package hmac implements the functions, types, and interfaces for the module. |
|
pbkdf2
Package pbkdf2 implements the functions, types, and interfaces for the module.
|
Package pbkdf2 implements the functions, types, and interfaces for the module. |
|
ripemd160
Package ripemd160 implements the functions, types, and interfaces for the module.
|
Package ripemd160 implements the functions, types, and interfaces for the module. |
|
sha
Package sha implements the functions, types, and interfaces for the module.
|
Package sha implements the functions, types, and interfaces for the module. |
|
examples
|
|
|
hash
command
Package main provides an example of using the hash package
|
Package main provides an example of using the hash package |
|
internal
|
|
|
Package scheme implements the functions, types, and interfaces for the module.
|
Package scheme implements the functions, types, and interfaces for the module. |
|
Package validator provides a common interface for algorithm-specific parameters.
|
Package validator provides a common interface for algorithm-specific parameters. |