utils

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePasswordAndHash

func ComparePasswordAndHash(password string, hash []byte) bool

ComparePasswordAndHash checks hash of password, returns true if they match, otherwise false

func GenerateRandomString

func GenerateRandomString(length int) string

GenerateRandomString generates random string and returns it

func HashPassword

func HashPassword(pass []byte) ([]byte, error)

HashPassword hashes password with bcrypt

func MustGetEnv

func MustGetEnv(key string) string

MustGetEnv retrieves the environment variable

Panics if doesn't exists

func MustParseEnvKey

func MustParseEnvKey(env string, size int) []byte

MustParseEnvKey parses base64 encoded public key, useful when you load it from ENV

Panics when ENV does not exists, or length is invalid

func NewRequestID

func NewRequestID(len int) ([]byte, error)

NewRequestID creates new random RequestID and returns it

func ParseSignedPayload

func ParseSignedPayload(p []byte) (string, []byte, error)

ParseSignedPayload parses payload, returns respectively message and signature

func ReturnError

func ReturnError(w http.ResponseWriter, err types.ResponseError)

ReturnError takes http.ResponseWriter and writes err to it

Types

This section is empty.

Jump to

Keyboard shortcuts

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