Files
tp/serv_golang_rest_api/internal/utils/password.go
T
valitovgaziz 83559faa4d new file: internal/utils/password.go
Add password utils hashPass and CheckPass functions
2025-09-29 00:58:34 +05:00

14 lines
392 B
Go

// 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
}