func (b *Engine) VerifySecret(secret, hash string) error {
	err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(secret))
	if err != nil {
		b.l.Debug("Bcrypt Error has occurred", "error", err)
		return crypto.ErrAuthorizationFailure
	}
	return nil
}
VerifySecret verifies a given secret against a given hash and
returns either nil for a match or a crypto.ErrAuthorizationFailure
in the case that the secret did not match the stored one.
package bcrypt
import (
	"github.com/hashicorp/go-hclog"
	"github.com/spf13/pflag"
	"github.com/spf13/viper"
	"golang.org/x/crypto/bcrypt"
	"github.com/netauth/netauth/internal/crypto"
	"github.com/netauth/netauth/internal/startup"
)
func init() {
	startup.RegisterCallback(cb)
	pflag.Int("crypto.bcrypt.cost", 15, "Cost for bcrypt")
}
func cb() {
	crypto.Register("bcrypt", New)
}
type Engine struct {
	cost int
	l    hclog.Logger
}
func New(l hclog.Logger) (crypto.EMCrypto, error) {
	x := new(Engine)
	x.cost = viper.GetInt("crypto.bcrypt.cost")
	x.l = l.Named("bcrypt")
	x.l.Debug("BCrypt Initialized", "cost", x.cost)
	return x, nil
}
func (b *Engine) SecureSecret(secret string) (string, error) {
	hash, err := bcrypt.GenerateFromPassword([]byte(secret), b.cost)
	if err != nil {
		b.l.Debug("Bcrypt Error has occurred", "error", err)
		return "", crypto.ErrInternalError
	}
	return string(hash[:]), nil
}