hash

package
v0.0.0-...-f4dfa5d Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Version = 1

Version is the hashing format version

Variables

This section is empty.

Functions

This section is empty.

Types

type Hasher

type Hasher interface {
	// CreateHash will return a hashed version of the secretKey, or an error
	CreateHash(secretKey string) (string, error)
	// VerifyHash will compare a secretKey and a hash, and return nil if they match
	VerifyHash(hash, secretKey string) error
}

Hasher is a generic interface for hashing algorithms

func NewSCrypt

func NewSCrypt() Hasher

NewSCrypt returns a scrypt hasher with recommended default values

type SCrypt

type SCrypt struct {
	N       int
	R       int
	P       int
	KeyLen  int
	SaltLen int
}

SCrypt contains all of the variables needed for scrypt hashing

func (SCrypt) CreateHash

func (s SCrypt) CreateHash(secretKey string) (string, error)

CreateHash will return a hashed version of the secretKey, or an error

func (SCrypt) VerifyHash

func (s SCrypt) VerifyHash(hash, secretKey string) error

VerifyHash will compare a secretKey and a hash, and return nil if they match

Jump to

Keyboard shortcuts

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