password

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(salt []byte, id, pass string, args ...int) (checkPass string)

Sign generates a string checkPass with PBKDF2 & SHA-3 by the user' id and pass. http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf recommended salt length >= 16 bytes default iter count is 12480 default result length is 64

fmt.Println(Sign([]byte("salt..."), "user_id", "user_password"))
fmt.Println(Sign([]byte("salt..."), "user_id", "user_password"), 1024) // iterCount == 1024
fmt.Println(Sign([]byte("salt..."), "user_id", "user_password"), 1024, 32)

func Verify

func Verify(salt []byte, id, pass, checkPass string, args ...int) bool

Verify verify user' id and password that generated by Sign

fmt.Println(Verify([]byte("salt..."), "user_id", "user_password", checkPass))

Types

type Password

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

Password -

func New

func New(salt []byte, args ...int) *Password

New returns a Password instance with given salt.

pw := New([]byte("salt..."))

func (*Password) Sign

func (p *Password) Sign(id, pass string) (checkPass string)

Sign sign password

fmt.Println(pw.Sign("user_id", "user_password"))

func (*Password) Verify

func (p *Password) Verify(id, pass, checkPass string) bool

Verify verify password

fmt.Println(pw.Verify("user_id", "user_password"), checkPass)

Jump to

Keyboard shortcuts

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