hash

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 17 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.

Index

Constants

View Source
const (
	// ENV environment variable name
	ENV = "ORIGADMIN_HASH_TYPE"
	// ErrPasswordNotMatch error when password not match
	ErrPasswordNotMatch = errors.String("password not match")
)

Variables

This section is empty.

Functions

func Generate

func Generate(password string) (string, error)

func GenerateWithSalt added in v0.0.20

func GenerateWithSalt(password, salt string) (string, error)

func RegisterAlgorithm added in v0.0.20

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

RegisterAlgorithm registers a new hash algorithm

func UseCrypto

func UseCrypto(t types.Type, opts ...types.Option) error

UseCrypto updates the default cryptographic instance

func Verify added in v0.0.20

func Verify(hashed, password string) error

Verify verifies a password

Types

type AlgorithmConfig added in v0.0.21

type AlgorithmConfig func() *types.Config

type AlgorithmCreator added in v0.0.21

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

type Crypto added in v0.3.3

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

func CachedCrypto added in v0.3.3

func CachedCrypto(crypto Crypto) Crypto

func NewCrypto added in v0.0.20

func NewCrypto(alg types.Type, opts ...types.Option) (Crypto, error)

NewCrypto creates a new cryptographic instance

Directories

Path Synopsis
algorithms
md5
sha
Package core implements the functions, types, and interfaces for the module.
Package core implements the functions, types, and interfaces for the module.
examples
hash command

Jump to

Keyboard shortcuts

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