hash

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 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

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

func RegisterAlgorithm

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

func Verify(hashed, password string) error

Verify verifies a password

Types

type AlgorithmConfig

type AlgorithmConfig func() *types.Config

type AlgorithmCreator

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

type Crypto

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

func CachedCrypto

func CachedCrypto(crypto Crypto) Crypto

func NewCrypto

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

NewCrypto creates a new cryptographic instance

Directories

Path Synopsis
algorithms
hmac
Package hmac implements the functions, types, and interfaces for the module.
Package hmac implements the functions, types, and interfaces for the module.
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
Package main provides an example of using the hash package
Package main provides an example of using the hash package

Jump to

Keyboard shortcuts

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