Passwords!

This commit is contained in:
2025-03-11 19:54:00 +02:00
parent 647edb6d25
commit 6661fdf89b
10 changed files with 128 additions and 18 deletions

14
internal/auth/auth.go Normal file
View File

@@ -0,0 +1,14 @@
package auth
import (
"golang.org/x/crypto/bcrypt"
)
func HashPassword(password string) (string, error) {
pass, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(pass), err
}
func CheckPasswordHash(password, hash string) error {
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
}