Documentation ¶
Index ¶
- func Encode(password string, opt *Option) (string, error)
- func EncodeFromKDF(password string, kdf KDF, salt string, hashLength uint32) (string, error)
- func GenerateRandomSalt(saltLength uint32) ([]byte, error)
- func KDFName(kdf KDF) (string, error)
- func ListKDFAlgorithms() []string
- func RegisterKDF(algorithm string, kdf KDF)
- func Verify(password, encoded string) (bool, error)
- type Argon2
- type Argon2i
- type Argon2id
- type HKDF
- type KDF
- type Option
- type PBKDF2
- type Scrypt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeFromKDF ¶ added in v1.0.0
EncodeFromKDF encode the password with the given KDF.
func GenerateRandomSalt ¶ added in v1.0.0
GenerateRandomSalt generates random salt.
func ListKDFAlgorithms ¶ added in v1.1.0
func ListKDFAlgorithms() []string
ListKDFAlgorithms list all the available kdf algorithms.
func RegisterKDF ¶ added in v1.0.0
RegisterKDF register a KDF with algorithm name.
Types ¶
type Argon2 ¶ added in v1.0.0
type Argon2 struct { Version uint8 `param:"v"` Memory uint32 `param:"m"` Iteration uint32 `param:"t"` Parallelism uint8 `param:"p"` }
Argon2 base params.
func (*Argon2) SetDefaultParam ¶ added in v1.0.0
func (kdf *Argon2) SetDefaultParam()
SetDefaultParam sets the default param for argon2.
type HKDF ¶ added in v1.0.0
HKDF params.
func (*HKDF) SetDefaultParam ¶ added in v1.0.0
func (kdf *HKDF) SetDefaultParam()
SetDefaultParam sets the default param for hkdf.
type KDF ¶
type KDF interface { SetDefaultParam() Derive(password, salt []byte, hashLength uint32) ([]byte, error) }
KDF should be implemented for different kdfs.
type Option ¶ added in v1.0.0
type Option struct { Algorithm string Param string RandomSaltLength uint32 Salt string HashLength uint32 }
Option for generating hash from KDF.
type PBKDF2 ¶
PBKDF2 params.
func (*PBKDF2) SetDefaultParam ¶ added in v1.0.0
func (kdf *PBKDF2) SetDefaultParam()
SetDefaultParam sets the default param for PBKDF2.
type Scrypt ¶ added in v1.0.0
type Scrypt struct { Cost int `param:"N"` BlockSize int `param:"r"` Parallelization int `param:"p"` }
Scrypt params.
func (*Scrypt) SetDefaultParam ¶ added in v1.0.0
func (kdf *Scrypt) SetDefaultParam()
SetDefaultParam sets the default param for scrypt.
Click to show internal directories.
Click to hide internal directories.