Implement user login with password hash verification and username lookup

This commit is contained in:
2025-05-15 12:24:48 +03:30
parent b3fae6b80c
commit d646515776
5 changed files with 39 additions and 8 deletions

View File

@@ -7,4 +7,9 @@ import (
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(bytes), err
}
func CheckPasswordHash(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}