password

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 9 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 {
	// contains filtered or unexported fields
}

BCrypt bcrypt password encryption

func NewBCrypt

func NewBCrypt(privateKey string) *BCrypt

NewBCrypt new bcrypt password encryption with key,if key empty use defaultPrivateKey.

func (BCrypt) Compare

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

Compare password hash verification

func (BCrypt) Hash

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

Hash password hash encryption

type Simple

type Simple struct {
	// contains filtered or unexported fields
}

Simple simple password encryption

func NewSimple

func NewSimple(key string) *Simple

NewSimple new simple password encryption with key

func (Simple) Compare

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

Compare password hash verification

func (Simple) Hash

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

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

type Verify

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

Verify verify interface

Jump to

Keyboard shortcuts

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