utils

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBase64 added in v1.1.1

func DecodeBase64(s string) (string, error)

DecodeBase64 decodes the base64 string

func GenerateECDSAKey

func GenerateECDSAKey() (*ecdsa.PrivateKey, error)

GenerateECDSAKey generates a new ECDSA key pair

func GenerateSecretPEMKey

func GenerateSecretPEMKey(filename string) error

GenerateSecretPEMKey generates a new PEM key pair

func GetEnv

func GetEnv(key string) string

GetEnv gets the environment variable

func GetPEMKeyPair

func GetPEMKeyPair(key *ecdsa.PrivateKey) (privKeyPEM []byte, pubKeyPEM []byte, err error)

GetPEMKeyPair reads the private key and returns the PrivateKey and publicKey

func HashAndSalt

func HashAndSalt(password string) (string, error)

HashAndSalt generates a hashed password

func IsRestrictedUser

func IsRestrictedUser(username string) bool

IsRestrictedUser checks if the user is restricted

func IsValidPassword

func IsValidPassword(s string) bool

IsValidPassword checks if the password (Strength) is valid

func IsValidUserName

func IsValidUserName(username string) bool

IsValidUserName checks if the username is valid

func ParseToken

func ParseToken(authorization string) (string, error)

ParseToken parses the token from authorization header

func ReadSecretKey

func ReadSecretKey(filename string) ([]byte, error)

ReadSecretKey reads the secret key from the file

func ToMaxAge

func ToMaxAge(expire time.Time) int

ToMaxAge converts the duration to max age

func ValidateUser

func ValidateUser(u *models.User) error

ValidateUser the user informations

func VerifyHash

func VerifyHash(password, hash string) bool

VerifyHash verifies the hashed password

Types

This section is empty.

Jump to

Keyboard shortcuts

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