utils

package
v0.0.0-...-17df326 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHashAndPassword

func CompareHashAndPassword(token []byte, pwd []byte) error

CompareHashAndPassword returns bool error if password and hash doesn't match

func CreateRandomByteSlice

func CreateRandomByteSlice(n int) ([]byte, error)

CreateRandomByteSlice will generate random bytes using crypto/rand package

func CreateRandomString

func CreateRandomString(n int) (string, error)

CreateRandomString converts byte slice to a base64 encoded string we don't use normal string conversion because random bytes may not be valid UTF8

func GenerateHash

func GenerateHash(byteSlice []byte) ([]byte, error)

GenerateHash generates bcrypt hash with default cost

func ParseForm

func ParseForm(dest interface{}, r *http.Request) error

ParseForm parses request body to given target

func PrettyPrint

func PrettyPrint(v interface{}) (err error)

PrettyPrint variable (struct, map, array, slice) in Golang

func RememberToken

func RememberToken() (string, error)

RememberToken return random generated string of predef size

Types

type HMAC

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

HMAC is a wrapper around crypt/hmac pkg

func NewHMAC

func NewHMAC(key string) HMAC

NewHMAC creates and returns new hmac object

func (HMAC) Hash

func (h HMAC) Hash(input string) string

Hash generates hash for given input with secret key of hmac object

Jump to

Keyboard shortcuts

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