Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultHashTime = 4 DefaultHashMemory = 64 * 1024 DefaultHashThreads = 4 DefaultHashKeyLength = 64 DefaultHashSaltLength = 16 )
Variables ¶
View Source
var ( ErrInvalidEncodedHash = errors.New("hash is in an unrecognizable format") ErrAlgorithmMismatch = errors.New("hash does not use argon2id") ErrVersionMismatch = errors.New("hash's argon2id version differs from current") ErrEmptyPassword = errors.New("password cannot be empty") )
View Source
var ( DefaultParameters = &Parameters{ Time: DefaultHashTime, Memory: DefaultHashMemory, Threads: DefaultHashThreads, KeyLength: DefaultHashKeyLength, SaltLength: DefaultHashSaltLength, } )
Functions ¶
func CheckPassword ¶
CheckPassword compares a string to a known encoded hash, using all the same parameters and salt as the known hash. In cases where you might expect a normal function to return an err, we'll just return false.
Types ¶
type Parameters ¶
type Parameters struct { Time uint32 // Number of passes to run Memory uint32 // Size of memory to use in KiB Threads uint8 // Number of threads to use KeyLength uint32 // Length of resulting hash SaltLength uint32 // Length of salt to generate }
func (*Parameters) HashPassword ¶
func (p *Parameters) HashPassword(password string) (encoded string, err error)
HashPassword returns an encoded string with all the necessary parameters encoded, separated by "$".
Click to show internal directories.
Click to hide internal directories.