Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCompareFailed = errors.New("crypt compare failed")
ErrCompareFailed compare failed
Functions ¶
This section is empty.
Types ¶
type BCrypt ¶
type BCrypt struct{}
BCrypt password encryption
func (BCrypt) CompareHashAndPassword ¶
CompareHashAndPassword password hash verification
type Complexity ¶ added in v0.0.3
type Complexity struct {
// contains filtered or unexported fields
}
Complexity setting
func NewComplexity ¶ added in v0.0.3
func NewComplexity(opts ...Option) *Complexity
NewComplexity new complexity with option default use lower, upper and digit to generate a random password, and not meets complexity.
func (*Complexity) Generate ¶ added in v0.0.3
func (sf *Complexity) Generate(n int) string
Generate a random password which is complex enough.
func (*Complexity) IsComplexEnough ¶ added in v0.0.3
func (sf *Complexity) IsComplexEnough(pwd string) bool
IsComplexEnough return True if password meets complexity settings
type Crypt ¶
type Crypt interface { GenerateFromPassword(password string) (string, error) CompareHashAndPassword(hashedPassword, password string) error }
Crypt crypt interface
type Option ¶ added in v0.0.3
type Option func(*complexityConfig)
Option for Complexity
func WithAll ¶ added in v0.0.3
func WithAll() Option
WithAll use lower upper digit spec and enable meet complexity
func WithLowerUpperDigit ¶ added in v0.0.3
func WithLowerUpperDigit() Option
WithLowerUpperDigit use lower upper digit
type SCrypt ¶
type SCrypt struct{}
SCrypt password encryption
func (SCrypt) CompareHashAndPassword ¶
CompareHashAndPassword password hash verification
type Simple ¶
type Simple struct{}
Simple password encryption
func (Simple) CompareHashAndPassword ¶
CompareHashAndPassword Compare password hash verification