hash

package
v0.0.0-...-0ddd045 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package hash provides multiple hash functions

Package hash provides multiple hash functions

Package hash provides multiple hash functions

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash         = errors.New("The encoded hash is not in the correct format")
	ErrIncompatibleVersion = errors.New("Incompatible version of argon2")
)
View Source
var DefaultArgon2Config = Argon2Config{
	Memory:      64 * constants.Argon2Kibibyte,
	Iterations:  5,
	Parallelism: uint8(runtime.NumCPU() / 4),
	SaltLength:  16,
	KeyLength:   32,
}

DefaultArgon2Config is the default config when using NewArgon2

Functions

func Adler32

func Adler32(payload string) string

Adler32 returns the Adler32 hash of 'payload'

func FNV128

func FNV128(payload string) string

FNV128 returns the FNV128 hash of 'payload'

func FNV64

func FNV64(payload string) string

FNV64 returns the FNV64 hash of 'payload'

func MD5

func MD5(payload string) string

MD5 returns the MD5 hash of 'payload'

Types

type Argon2

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

func NewArgon2

func NewArgon2() Argon2

NewArgon2 returns a new Argon2 hasher with the default config

func NewArgon2WithConfig

func NewArgon2WithConfig(c Argon2Config) Argon2

NewArgon2WithConfig returns a new Argon2 hasher with a custom config

func (Argon2) Hash

func (a Argon2) Hash(payload string) (string, error)

Hash hashes the payload

func (Argon2) Name

func (a Argon2) Name() string

Name returns the name of the hasher

func (Argon2) Valid

func (a Argon2) Valid(input, hashed string) (bool, error)

Valid compares the input to a hashed payload

type Argon2Config

type Argon2Config struct {
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
	SaltLength  uint32
	KeyLength   uint32
}

type Hash

type Hash interface {
	Hash(string) (string, error)
	Valid(string, string) (bool, error)
}

Jump to

Keyboard shortcuts

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