diff options
author | Santo Cariotti <santo@dcariotti.me> | 2025-04-02 19:31:12 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2025-04-02 19:37:12 +0200 |
commit | a9b84f3f3b1d92335188d43048587e32e0921079 (patch) | |
tree | a4313f7660a99745d7d5da4d92dc9509d0dbe35e /pkg | |
parent | 2e92ccd66eb5c31b8fbbcd205d7b4a882450e9d0 (diff) |
Init login and frontend
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/utils.go | 13 |
1 files changed, 13 insertions, 0 deletions
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 +} |