password

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCompareFailed = errors.New("crypt 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) CompareHashAndPassword added in v0.4.0

func (sf BCrypt) CompareHashAndPassword(hashedPassword, password string) error

CompareHashAndPassword password hash verification

func (BCrypt) GenerateFromPassword added in v0.4.0

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

GenerateFromPassword password hash encryption

type Crypt added in v0.4.0

type Crypt interface {
	GenerateFromPassword(password string) (string, error)
	CompareHashAndPassword(hashedPassword, password string) error
}

Crypt crypt interface

type SCrypt

type SCrypt struct{}

SCrypt scrypt password encryption

func (SCrypt) CompareHashAndPassword added in v0.4.0

func (SCrypt) CompareHashAndPassword(hashedPassword, password string) error

CompareHashAndPassword password hash verification

func (SCrypt) GenerateFromPassword added in v0.4.0

func (SCrypt) GenerateFromPassword(password string) (string, error)

GenerateFromPassword password hash encryption

type Simple

type Simple struct{}

Simple simple password encryption

func (Simple) CompareHashAndPassword added in v0.4.0

func (sf Simple) CompareHashAndPassword(hashedPassword, password string) error

Compare password hash verification

func (Simple) GenerateFromPassword added in v0.4.0

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

Hash password hash encryption 加盐法

Jump to

Keyboard shortcuts

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