utils

package
v0.0.0-...-9829ae4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

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")
)

Functions

func CheckPassword

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

CheckPassword checks that the provided password matches the hashed password.

func Child

func Child() bool

func Debug

func Debug() bool

func DebugExec

func DebugExec(function func())

func FromJson

func FromJson(source []byte) interface{}

func FromJsonToObject

func FromJsonToObject(source []byte, destination interface{}) error

func FromJsonToObjectMultiple

func FromJsonToObjectMultiple(source [][]byte, destination interface{}) error

func GenerateRandomBytes

func GenerateRandomBytes(n uint32) ([]byte, error)

generateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomSession

func GenerateRandomSession() []byte

Generate a random UUID for the session

func HashBytesSHA512

func HashBytesSHA512(inputBytes []byte) string

Hash with SHA512

func HashMD5

func HashMD5(text string) string

func HashPassword

func HashPassword(password string) (encodedHash string, err error)

HashPassword returns a Argon2id hash of a password with the given parameters.

func HashSHA512

func HashSHA512(input string) string

Hash with SHA512

func InterfaceToObject

func InterfaceToObject(input interface{}, output interface{}) error

func NonChildExec

func NonChildExec(function func())

func RandomAlphanumeric

func RandomAlphanumeric(length int) (string, error)

Generate a random alphanumeric string

func StripeEnabledExec

func StripeEnabledExec(function func())

func ToJson

func ToJson(source interface{}) []byte

Types

type Argon2Params

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

func DecodeHash

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

decodeHash extracts the parameters, salt and derived key from an encoded argon2 password hash.

type Time

type Time int64

func FromTimestamp

func FromTimestamp(timestamp int64) Time

func GetTimestamp

func GetTimestamp() Time

func (Time) Add

func (t Time) Add(time time.Duration) Time

func (Time) Format

func (t Time) Format() string

func (Time) FormattedDate

func (t Time) FormattedDate() string

func (Time) FormattedTime

func (t Time) FormattedTime() string

func (Time) Int64

func (t Time) Int64() int64

func (Time) Passed

func (t Time) Passed() bool

func (Time) Weekday

func (t Time) Weekday() string

Jump to

Keyboard shortcuts

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