From a9b84f3f3b1d92335188d43048587e32e0921079 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 2 Apr 2025 19:31:12 +0200 Subject: Init login and frontend --- pkg/utils.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pkg/utils.go (limited to 'pkg') diff --git a/pkg/utils.go b/pkg/utils.go new file mode 100644 index 0000000..f5a443e --- /dev/null +++ b/pkg/utils.go @@ -0,0 +1,13 @@ +package utils + +import "golang.org/x/crypto/bcrypt" + +func HashPassword(password string) (string, error) { + bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14) + return string(bytes), err +} + +func CheckPasswordHash(password, hash string) bool { + err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) + return err == nil +} -- cgit v1.2.3-18-g5258