Files
AuthCentral/pkg/utils/password.go
Beyhan Oğur 8b1fbdee99 first commit
2026-04-26 21:37:58 +03:00

16 lines
365 B
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
}