password

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCompareFailed = errors.New("verify compare failed")

ErrCompareFailed compare failed

Functions

func Generate

func Generate(n int) (string, error)

Generate a random password

func IsComplexEnough

func IsComplexEnough(pwd string) bool

IsComplexEnough return True if password meets complexity settings

func SetupComplexity

func SetupComplexity(values []string)

SetupComplexity setup complexity with values value can set lower,upper,digit,spec default use lower, upper and digit to generate a random password, and not meets complexity.

Types

type BCrypt

type BCrypt struct{}

BCrypt bcrypt password encryption

func (BCrypt) Compare

func (sf BCrypt) Compare(password, salt, hash string) error

Compare password hash verification

func (BCrypt) Hash

func (sf BCrypt) Hash(password, salt string) (string, error)

Hash password hash encryption

type SCrypt added in v0.1.3

type SCrypt struct{}

SCrypt scrypt password encryption

func (SCrypt) Compare added in v0.1.3

func (sf SCrypt) Compare(password, salt, hash string) error

Compare password hash verification

func (SCrypt) Hash added in v0.1.3

func (sf SCrypt) Hash(password, salt string) (string, error)

Hash password hash encryption

type Simple

type Simple struct{}

Simple simple password encryption

func (Simple) Compare

func (sf Simple) Compare(password, salt, hash string) error

Compare password hash verification

func (Simple) Hash

func (sf Simple) Hash(password, salt string) (string, error)

Hash password hash encryption 加盐法 md5Pwd+`@#$%`+md5Pwd+`^&*()`拼接

type Verify

type Verify interface {
	Hash(password, salt string) (string, error)
	Compare(password, salt, hash string) error
}

Verify verify interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL