Documentation ¶
Index ¶
Constants ¶
View Source
const ( Bcrypt EncoderType = "bcrypt" // use bcrypt hash Scrypt EncoderType = "scrypt" // use scrypt hash Pbkdf2 EncoderType = "pbkdf2" // use pbkdf2 hash Argon2 EncoderType = "argon2" // use argon2 hash Hkdf EncoderType = "hkdf" // use hkdf hash SaltLen int = 16 // default size of salt value DefaultKeyLen = 32 )
Variables ¶
View Source
var DefaultHashFunc = sha256.New
Functions ¶
func GenerateRandomSalt ¶
GenerateRandomSalt generates random salt.
Types ¶
type Encoder ¶
type Encoder interface { // Encode returns the hash value of the given data Encode(src string) (string, error) // Verify compares a encoded data with its possible plaintext equivalent Verify(hash string, rawData string) (bool, error) // GetSalt Returns the salt if exists, otherwise nil GetSalt() ([]byte, error) }
type EncoderType ¶
type EncoderType string
type OptionFunc ¶
type OptionFunc func(e Encoder)
OptionFunc wraps a func so it satisfies the Option interface.
Click to show internal directories.
Click to hide internal directories.