hash

package
v0.3.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

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.

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.

Index

Constants

View Source
const (
	// ENV environment variable name
	ENV = "ORIGADMIN_HASH_TYPE"
)

Variables

View Source
var (

	// ErrHashModuleNotInitialized is returned when the hash module fails to initialize.
	ErrHashModuleNotInitialized = errors.ErrHashModuleNotInitialized
)

Functions

func AvailableAlgorithms added in v0.3.18

func AvailableAlgorithms() []types.Type

AvailableAlgorithms returns a list of all registered hash algorithms.

func Generate

func Generate(password string) (string, error)

Generate generates a hash for the given password using the active cryptographic instance.

func GenerateWithSalt

func GenerateWithSalt(password string, salt []byte) (string, error)

GenerateWithSalt generates a hash for the given password with the specified salt using the active cryptographic instance.

func NewCachedVerifier added in v0.3.18

func NewCachedVerifier(wrapped interfaces.Cryptographic) interfaces.Cryptographic

NewCachedVerifier creates a new cachedVerifier that wraps the given Cryptographic implementation.

func RegisterAlgorithm

func RegisterAlgorithm(algType types.Type, creator AlgorithmCreator, defaultConfig AlgorithmConfig)

RegisterAlgorithm registers a new hash algorithm

func RegisterAlgorithmResolver added in v0.3.18

func RegisterAlgorithmResolver(name string, resolver interfaces.AlgorithmResolver)

RegisterAlgorithmResolver registers a resolver for a specific algorithm name.

func ResolveType added in v0.3.18

func ResolveType(algType types.Type) (types.Type, error)

func UseCrypto

func UseCrypto(algName string, opts ...types.Option) error

UseCrypto updates the active cryptographic instance

func Verify

func Verify(hashed, password string) error

Verify verifies a password using the active cryptographic instance.

Types

type AlgorithmConfig

type AlgorithmConfig func() *types.Config

type AlgorithmCreator

type AlgorithmCreator func(algType types.Type, cfg *types.Config) (interfaces.Cryptographic, error)

AlgorithmCreator now accepts the full types.Type struct

type Crypto

type Crypto interface {
	Type() types.Type
	Hash(password string) (string, error)
	HashWithSalt(password string, salt []byte) (string, error)
	Verify(hashed, password string) error
}

func NewCrypto

func NewCrypto(algName string, opts ...types.Option) (Crypto, error)

NewCrypto creates a new cryptographic instance

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.
md5
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
Package interfaces implements the functions, types, and interfaces for the module.
Package interfaces implements the functions, types, and interfaces for the module.
internal
validator
Package validator implements the functions, types, and interfaces for the module.
Package validator implements the functions, types, and interfaces for the module.
Package types implements the functions, types, and interfaces for the module.
Package types implements the functions, types, and interfaces for the module.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL