utils

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(msg string, err error) error

CheckErr checks if an error is not nil and returns a formatted error message. If the error is nil, it returns nil.

Parameters:

  • msg: A string message to prepend to the error message.
  • err: The error to check.

Returns:

  • An error with the formatted message if err is not nil, otherwise nil.

func GenerateRandomSalt

func GenerateRandomSalt() ([]byte, error)

GenerateRandomSalt generates a random salt of 32 bytes.

Returns:

  • A byte slice containing the random salt.
  • An error if the random salt generation fails.

func HashPassword added in v1.0.2

func HashPassword(password string) []byte

HashPassword hashes the input password using SHA-256. It returns the hashed password as a byte slice.

func ValidatePassword added in v1.0.2

func ValidatePassword(inputPassword string, savedHash []byte) bool

ValidatePassword compares the input password with the saved hash. It returns true if the passwords match, false otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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