package crypto import "golang.org/x/crypto/bcrypt" const bcryptCost = 12 func hashPasswordBcrypt(password string) (string, error) { bytes, err := bcrypt.GenerateFromPassword([]byte(password), bcryptCost) if err != nil { return "", err } return string(bytes), nil } func verifyPasswordBcrypt(password, hash string) bool { err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) return err == nil }