29 lines
655 B
Go
29 lines
655 B
Go
package crypto
|
|
|
|
import "html/template"
|
|
import "golang.org/x/crypto/bcrypt"
|
|
import "git.tebibyte.media/sashakoshka/step"
|
|
|
|
var _ step.FuncProvider = new(Provider)
|
|
|
|
// Provider provides cryptographic functions.
|
|
type Provider struct {
|
|
|
|
}
|
|
|
|
// Package fulfills the step.Provider interface.
|
|
func (this *Provider) Package () string {
|
|
return "crypto"
|
|
}
|
|
|
|
// FuncMap fulfills the step.FuncProvider interface.
|
|
func (this *Provider) FuncMap () template.FuncMap {
|
|
return template.FuncMap {
|
|
"bcryptCompare": funcBcryptCompare,
|
|
}
|
|
}
|
|
|
|
func funcBcryptCompare (hash string, text string) bool {
|
|
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(text)) == nil
|
|
}
|