utils

package
v0.0.0-...-eccf771 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorBadRequestBody = "Bad Request body. Make sure it is properly formatted json"
)

Variables

View Source
var (
	ErrInvalidHash         = errors.New("the encoded hash is not in the correct format")
	ErrIncompatibleVersion = errors.New("incompatible version of argon2")
)

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, data interface{})

func ComparePasswordAndHash

func ComparePasswordAndHash(password, encodedHash string) (match bool, err error)

func HashPasswd

func HashPasswd(password string, p *ArgonParams) (encodedHash string, err error)

func InternalServerError

func InternalServerError(w http.ResponseWriter, data interface{})

func NotFound

func NotFound(w http.ResponseWriter, data interface{})

func OK

func OK(w http.ResponseWriter, data interface{})

func Send

func Send(w http.ResponseWriter, status int, data interface{})

func Unauthorized

func Unauthorized(w http.ResponseWriter)

Types

type ArgonParams

type ArgonParams struct {
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
	SaltLength  uint32
	KeyLength   uint32
}
var DefaultArgonParams ArgonParams = ArgonParams{
	Memory:      64 * 1024,
	Iterations:  3,
	Parallelism: 2,
	SaltLength:  16,
	KeyLength:   32,
}

Default params for argon2id password hashing. These parameters are not audited and hence you should choose strong enough parameters for your usecase.

func DecodeHash

func DecodeHash(encodedHash string) (p *ArgonParams, salt, hash []byte, err error)

type GenericResult

type GenericResult struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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