hash

package
v0.0.0-...-d5dcd45 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package hash implements the password hashing algorithms.

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectPassword = errors.New("password is not correct")

ErrIncorrectPassword is returned when the provided password is incorrect.

Functions

This section is empty.

Types

type Argon2Hasher

type Argon2Hasher struct {
	// contains filtered or unexported fields
}

Argon2Hasher uses Argon2 to hash passwords with random salt.

func NewArgon2Hasher

func NewArgon2Hasher(opts ...Option) Argon2Hasher

NewArgon2Hasher creates a new Argon2Hasher.

func (Argon2Hasher) Check

func (ah Argon2Hasher) Check(plain, hash string) error

Check checks if the provided password is correct or not.

func (Argon2Hasher) Hash

func (ah Argon2Hasher) Hash(plain string) (string, error)

Hash returns the argon2 hash of the password.

type Option

type Option func(*Argon2Hasher)

Option is a function that can be used to customize the Argon2Hasher.

func KeyLen

func KeyLen(keyLen uint32) Option

KeyLen sets the custom key length parameter of the Argon2 algorithm.

func Memory

func Memory(memory uint32) Option

Memory sets the custom memory parameter of the Argon2 algorithm.

func SaltLen

func SaltLen(saltLen uint32) Option

SaltLen sets the custom salt length parameter of the Argon2 algorithm.

func Threads

func Threads(threads uint8) Option

Threads sets the custom threads parameter of the Argon2 algorithm.

func Time

func Time(time uint32) Option

Time sets the custom time parameter of the Argon2 algorithm.

Jump to

Keyboard shortcuts

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