Files
access-handler/utils/hash.go
Adrian Zürcher 4db4262195 first commit
2025-10-24 10:31:19 +02:00

15 lines
371 B
Go

package utils
import "golang.org/x/crypto/bcrypt"
// Hash password
func HashPassword(password string) (string, error) {
b, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(b), err
}
// Check password
func CheckPassword(password, hash string) bool {
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) == nil
}