utils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSalt

func GenerateSalt() ([]byte, error)

Usage

salt, err := generateSalt()

if err != nil {
	log.Fatal("Failed to generate salt:", err)
}

func GetFirst added in v1.0.1

func GetFirst(values ...string) string

func HashPassword

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

Usage NOTE: Store both the hash and salt in the database, it is needed to verify the password

hash, salt := hashPassword(password, salt)

func VerifyPassword

func VerifyPassword(storedHash, storedSalt, password string) (bool, error)

Usage

isValid, err := verifyPassword(hashedPassword, hashedSalt, password)

if err != nil {
	log.Fatal("Failed to verify password:", err)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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