util

package
v0.0.0-...-6de58e6 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(pass string, salt string, hash string) bool

ComparePassword compares pass with salt and hash and returns true if it's valid You must provide the base64 encoded salt and hash to this function.

func CreateToken

func CreateToken() (string, string)

CreateToken creates a session-based auth token and sha256 hash of it and returns them The token and token hash are base64 encoded.

func GenerateHash

func GenerateHash(pass string, salt []byte) []byte

GenerateHsh takes a password and salt byte array and returns a byte array containing an argon2 key

func GenerateSalt

func GenerateSalt(len int) []byte

func ProcessPassword

func ProcessPassword(pass string) (string, string)

ProcessPassword returns the base64 encoded salt and base64 encoded argon2 hash or an error

func TryBind

func TryBind(obj any, c *gin.Context) (error, gin.H)

func ValidateToken

func ValidateToken(token string, hash string) bool

ValidateToken takes base64 encoded token and token hash and returns true if they are equal when the token is decoded and sha256'd.

Types

This section is empty.

Jump to

Keyboard shortcuts

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