Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHashArgon2 ¶
CheckPasswordHashArgon2 verifies if a given plain password matches the Base58-encoded hash. Returns true if they match, false otherwise.
func CheckPasswordHashBcrypt ¶
CheckPasswordHashBcrypt compares a bcrypt hashed password with its possible plain text equivalent. Returns true if the password matches the hash, false otherwise.
Example:
match := CheckPasswordHashBcrypt("mySecret123", storedHash)
func HashPasswordArgon2 ¶
HashPasswordArgon2 generates a secure, encoded Argon2ID hash string using Base58. It marshals the hash, salt, and params into a JSON structure and encodes it. Returns a Base58 encoded string safe to store in databases or configuration.
func HashPasswordBcrypt ¶
HashPasswordBcrypt hashes the given plain text password using the bcrypt algorithm. It returns the hashed password as a string and any error encountered during hashing.
Example:
hash, err := HashPasswordBcrypt("mySecret123")
if err != nil { ... }
Types ¶
type Hash ¶
type Hash struct {
Data []byte `json:"data"`
Salt []byte `json:"salt"`
Params *Params `json:"params"`
}
Hash represents the encoded structure used to store a hashed password, including the derived hash, salt, and the parameters used.
type Params ¶
type Params struct {
Memory uint32 `json:"m"` // Memory in KB
Iterations uint32 `json:"i"` // Number of iterations
Parallelism uint8 `json:"p"` // Number of parallel threads
SaltLength uint32 `json:"s"` // Length of the random salt
KeyLength uint32 `json:"k"` // Desired length of the resulting key
}
Params holds configuration for the Argon2ID hash function. It includes memory usage, number of iterations, parallelism, salt length, and resulting key length.