package tools import "golang.org/x/crypto/bcrypt" // HashPassword hashes a password using bcrypt. func HashPassword(password string) (string, error) { bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) return string(bytes), err } // CheckPassword verifies a password against a bcrypt hash. func CheckPassword(hashed, password string) bool { err := bcrypt.CompareHashAndPassword([]byte(hashed), []byte(password)) return err == nil }