Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argon2Hasher ¶
type Argon2Hasher struct {
// contains filtered or unexported fields
}
Argon2Hasher implements the Hasher interface using the Argon2id algorithm.
func NewArgon2Hasher ¶
func NewArgon2Hasher(memory uint32, iterations uint32, parallelism uint8, saltLength uint32, keyLength uint32) *Argon2Hasher
NewArgon2Hasher creates a new Argon2Hasher with OWASP recommended safe defaults.
func (*Argon2Hasher) Check ¶
func (a *Argon2Hasher) Check(value, hashed string) bool
Check verifies that the given string matches the hash.
func (*Argon2Hasher) Make ¶
func (a *Argon2Hasher) Make(value string) (string, error)
Make hashes the given string using Argon2id.
func (*Argon2Hasher) NeedsRehash ¶
func (a *Argon2Hasher) NeedsRehash(hashed string) bool
NeedsRehash determines if the hash needs to be recomputed due to config changes.
type BcryptHasher ¶
type BcryptHasher struct {
// contains filtered or unexported fields
}
BcryptHasher implements the Hasher interface using the bcrypt algorithm.
func NewBcryptHasher ¶
func NewBcryptHasher(cost int) *BcryptHasher
NewBcryptHasher creates a new BcryptHasher with the given cost factor. Defaults to 12 if cost is 0.
func (*BcryptHasher) Check ¶
func (b *BcryptHasher) Check(value, hashed string) bool
Check verifies that the given string matches the hash.
func (*BcryptHasher) Make ¶
func (b *BcryptHasher) Make(value string) (string, error)
Make hashes the given string using bcrypt.
func (*BcryptHasher) NeedsRehash ¶
func (b *BcryptHasher) NeedsRehash(hashed string) bool
NeedsRehash determines if the given hash needs to be rehashed based on current cost.
type Hasher ¶
type Hasher interface {
// Make hashes the given string.
Make(value string) (string, error)
// Check verifies that the given plain text string matches the hash.
Check(value, hashed string) bool
// NeedsRehash determines if the given hash has been hashed using the configured options.
NeedsRehash(hashed string) bool
}
Hasher provides an interface for password hashing mechanisms.
type SHA512Hasher ¶
type SHA512Hasher struct {
// contains filtered or unexported fields
}
SHA512Hasher implements the Hasher interface using SHA-512 (for non-password hashing).
func NewSHA512Hasher ¶
func NewSHA512Hasher() *SHA512Hasher
NewSHA512Hasher creates a new SHA512Hasher.
func (*SHA512Hasher) Check ¶
func (h *SHA512Hasher) Check(value, hashed string) bool
Check verifies that the given string matches the hash.
func (*SHA512Hasher) Make ¶
func (h *SHA512Hasher) Make(value string) (string, error)
Make hashes the given string using SHA-512 with salt.
func (*SHA512Hasher) NeedsRehash ¶
func (h *SHA512Hasher) NeedsRehash(hashed string) bool
NeedsRehash always returns false for SHA-512 (no configurable cost).
type ScryptHasher ¶
type ScryptHasher struct {
N int
// contains filtered or unexported fields
}
ScryptHasher implements the Hasher interface using the scrypt algorithm.
func NewScryptHasher ¶
func NewScryptHasher() *ScryptHasher
NewScryptHasher creates a new ScryptHasher with OWASP-recommended parameters.
func (*ScryptHasher) Check ¶
func (s *ScryptHasher) Check(value, hashed string) bool
Check verifies that the given string matches the hash.
func (*ScryptHasher) Make ¶
func (s *ScryptHasher) Make(value string) (string, error)
Make hashes the given string using scrypt.
func (*ScryptHasher) NeedsRehash ¶
func (s *ScryptHasher) NeedsRehash(hashed string) bool
NeedsRehash determines if the hash needs to be rehashed.