utils

package
Version: v0.0.0-...-64e84b0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PasswordValidator validator.Func = func(fl validator.FieldLevel) bool {
	lenCheck := len(fl.Field().String()) >= 8
	hasDigit := false
	hasLetter := false
	hasCapital := false
	hasSpecial := false

	for _, c := range fl.Field().String() {
		if c >= '0' && c <= '9' {
			hasDigit = true
		} else if c >= 'a' && c <= 'z' {
			hasLetter = true
		} else if c >= 'A' && c <= 'Z' {
			hasCapital = true
		} else {
			hasSpecial = true
		}
	}

	return lenCheck && hasDigit && hasLetter && hasCapital && hasSpecial
}

Functions

func CheckHash

func CheckHash(password string, hash string) bool

func GenerateToken

func GenerateToken(l ...int) (string, error)

func GenerateTokenWithAlphabet

func GenerateTokenWithAlphabet(length int, alphabet string) (string, error)

func Getenv

func Getenv(key string, defaultValue string) string

func HashPassword

func HashPassword(password string) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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