Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UnsupportedHashTypeError = errors.New("Unsupported hash type") UnsupportedHashVersionError = errors.New("Unsupported hash version") )
View Source
var ( // DefaultHashParams are the default parameters for the hashing algorithm DefaultHashParams = HashParams{ Time: 2, Memory: 256 * 1024, Threads: 4, KeyLen: 32, SaltLength: 32, Type: Argon2id, Version: argon2.Version, } )
View Source
var (
InvalidEncodedHashError = errors.New("Invalid encoded hash")
)
View Source
var SaltGenerationError = errors.New("Failed to generate salt")
Functions ¶
Types ¶
type Argon2Type ¶
type Argon2Type uint8
const ( Argon2d Argon2Type = iota Argon2i Argon2id )
Argon2 types according to the RFC
type HashParams ¶
type HashParams struct {
Time uint32 // Number of iterations/passes over the memory (-> time) used by the algorithm
Memory uint32 // Amount of memory used by the algorithm in KiB (minimum: 8*Threads)
Threads uint8 // Parallelism factor determines how many independent (but synchronizing) computational chains (lanes) can be run
KeyLen uint32 // Length of the generated hash (key) in bytes. Recommended: 16 or more
SaltLength uint32 // Length of the random salt in bytes. Recommended: 16 or more
Type Argon2Type // Type of the algorithm: 0 = Argon2d, 1 = Argon2i, 2 = Argon2id
Version uint32 // Version of the algorithm
}
HashParams are the parameters for the hashing algorithm. Description according to RFC-9106.
func DecodeHash ¶
DecodeHash decodes the hash, parameters and salt from the encoded hash
func (*HashParams) EncodeHash ¶
EncodeHash encodes the hash and salt using the provided parameters
func (*HashParams) GenerateSalt ¶
func (params *HashParams) GenerateSalt(ctx context.Context) ([]byte, error)
GenerateSalt generates a random salt with the length specified in the HashParams struct
func (*HashParams) HashPassword ¶
HashPassword generates a salt and hashes the provided password using the Argon2id algorithm
Click to show internal directories.
Click to hide internal directories.