Documentation
¶
Index ¶
- Variables
- func CompareScrypt(password, encodedHash string) error
- func GenerateScrypt(password string, params ScryptParams) (string, error)
- func NewErrCompareScrypt(err error) error
- func NewErrDecodeHash(err error) error
- func NewErrGenerateScrypt(err error) error
- func NewErrNewRandomURLString(err error) error
- func NewRandomURLString(length int) (string, error)
- type ScryptParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidHash = errors.New("the encoded hash is in an invalid format") ErrIncompatibleVersion = errors.New("the encoded hash is using an incompatible version of Argon2") ErrInvalidPassword = errors.New("the password is invalid") ErrGenerateScrypt = errors.New("GenerateScrypt") ErrCompareScrypt = errors.New("CompareScrypt") ErrDecodeHash = errors.New("decodeHash") )
View Source
var ErrNewRandomURLString = errors.New("NewRandomURLString")
View Source
var ScryptParamsDefault = ScryptParams{
SaltLength: 32,
Iterations: 1,
Memory: 64 * 1024,
Parallelism: 4,
KeyLength: 32,
}
View Source
var URLCharList = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
URLCharList is a list of URL-valid characters, for generating random strings.
Functions ¶
func CompareScrypt ¶
CompareScrypt compares a password with an encoded hash generated by GenerateScrypt. It returns true if the password matches the hash, and false otherwise.
This method is similar to bcrypt.CompareHashAndPassword, but based on the newer Argon2 algorithm.
func GenerateScrypt ¶
func GenerateScrypt(password string, params ScryptParams) (string, error)
GenerateScrypt is a secure hash method, similar to bcrypt.GenerateFromPassword, but based on the newer Argon2 algorithm.
func NewErrCompareScrypt ¶
func NewErrDecodeHash ¶
func NewErrGenerateScrypt ¶
func NewRandomURLString ¶
Types ¶
type ScryptParams ¶
type ScryptParams struct {
// SaltLength is the length of the salt in bytes.
SaltLength uint
// Iterations is the number of iterations to use.
Iterations uint32
// Memory is the amount of memory used by the algorithm.
Memory uint32
// Parallelism is the number of threads to use.
Parallelism uint8
// KeyLength is the length of the derived key.
KeyLength uint32
}
ScryptParams contains the parameters used to generate a hash using the Argon2 algorithm.
You can use ScryptParamsDefault unless you have specific requirements.
Click to show internal directories.
Click to hide internal directories.