new file: internal/utils/password.go

Add password utils hashPass and CheckPass functions
This commit is contained in:
2025-09-29 00:58:34 +05:00
parent 6adc52aa27
commit 83559faa4d
@@ -0,0 +1,14 @@
// utils/password.go
package utils
import "golang.org/x/crypto/bcrypt"
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
}