Documentation ¶
Overview ¶
Example (Verify) ¶
hasher := new(PBKDF2Hasher) pwd := "testpwd" hash := hasher.EncodeDefault(pwd) ok, _ := hasher.Verify(pwd, hash) fmt.Printf("%v", ok) ok, _ = hasher.Verify("wrongPwd", hash) fmt.Printf("%v", ok)
Output: truefalse
Index ¶
- Constants
- Variables
- type PBKDF2Hasher
- func (p PBKDF2Hasher) Decode(str string) (dict map[string]string, err error)
- func (p PBKDF2Hasher) Encode(pwd, salt string, iterations int) string
- func (p PBKDF2Hasher) EncodeDefault(pwd string) string
- func (p PBKDF2Hasher) GenSalt(size int) string
- func (p *PBKDF2Hasher) Verify(pwd string, cipher string) (bool, error)
Examples ¶
Constants ¶
View Source
const ( Iterations = 120000 SaltSize = 12 Keylen = 256 / 8 Hasher = "pbkdf2_sha256" )
Variables ¶
View Source
var ( ErrHasher = errors.New("Invalid hash algorithm") ErrFmt = errors.New("Format can not be parsed") )
Functions ¶
This section is empty.
Types ¶
type PBKDF2Hasher ¶
type PBKDF2Hasher struct { }
func (PBKDF2Hasher) Decode ¶
func (p PBKDF2Hasher) Decode(str string) (dict map[string]string, err error)
Decode just splits string by $
func (PBKDF2Hasher) Encode ¶
func (p PBKDF2Hasher) Encode(pwd, salt string, iterations int) string
Encode as defined in RFC 2898
func (PBKDF2Hasher) EncodeDefault ¶
func (p PBKDF2Hasher) EncodeDefault(pwd string) string
EncodeDefault as defined in RFC 2898 and default args in const
func (PBKDF2Hasher) GenSalt ¶
func (p PBKDF2Hasher) GenSalt(size int) string
GenSalt Generate a cryptographically secure nonce salt in ASCII.
Click to show internal directories.
Click to hide internal directories.