utils

package
v0.0.0-...-2f60b96 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgonParams

type ArgonParams struct {
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
	SaltLength  uint32
	KeyLength   int
	SaltKey     []byte
}

type Utils

type Utils struct {
	ArgonParams
	// contains filtered or unexported fields
}

func NewUtils

func NewUtils(a *config.AppConfig) *Utils

NewUtils is a utility helper to take care of certain tasks It needs the app config passed into it so it can have access to app wide items

func (*Utils) CreateArgonHash

func (u *Utils) CreateArgonHash(plainTextPW string) string

func (*Utils) DecodeHash

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

func (*Utils) ErrorJSON

func (u *Utils) ErrorJSON(w http.ResponseWriter, r *http.Request, envelope string, data interface{}, statusCode int, headers ...http.Header) error

func (*Utils) GenerateActivationToken

func (u *Utils) GenerateActivationToken() (string, error)

func (*Utils) GenerateRandomBytes

func (u *Utils) GenerateRandomBytes(saltLength uint32) ([]byte, error)

func (*Utils) IsRequired

func (u *Utils) IsRequired(s interface{}, key string) bool

func (*Utils) ValidatePhoneNumber

func (u *Utils) ValidatePhoneNumber(s string) bool

ValidatePhoneNumber takes in a phone number as a text string, and runs a regex match on it and returns the result as a bool

func (*Utils) VerifyArgonHash

func (u *Utils) VerifyArgonHash(plaintextPW string, previousHash string) bool

func (*Utils) WriteJSON

func (u *Utils) WriteJSON(w http.ResponseWriter, r *http.Request, envelope string, data interface{}, statusCode int, headers ...http.Header) error

WriteJSON takes in a responseWriter, request, enveolor, and data and write json to the response writer. it can return a potential error to pass in headers use headers := make(http.Header)

type Utilser

type Utilser interface {
	ValidatePhoneNumber(string) bool
	WriteJSON(w http.ResponseWriter, r *http.Request, envelope string, data interface{}) error
	ErrorJSON(w http.ResponseWriter, r *http.Request, enveloper string, data interface{}, statusCode int, headers ...http.Header) error
	CreateArgonHash(string, []byte) string
	GenerateRandomBytes(uint32) ([]byte, error)
	VerifyArgonHash(string, []byte) bool
	GenerateActivationToken() (string, error)
}

Jump to

Keyboard shortcuts

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