Documentation
¶
Overview ¶
Package sha2 provides hashing and verification of SHA-256 and SHA-512 encoded passwords with salt based on crypt(3). [The algorithm](https://www.akkadia.org/drepper/SHA-crypt.txt) builds hashes through multiple digest iterations with shuffles of password and salt.
Index ¶
Constants ¶
View Source
const ( Sha256Identifier = "$5$" Sha512Identifier = "$6$" SaltLenMin = 1 SaltLenMax = 16 RoundsMin = 1000 RoundsMax = 999999999 RoundsDefault = 5000 )
Variables ¶
View Source
var DefaultValidationOpts = &ValidationOpts{ MinSha256Rounds: RoundsMin, MaxSha256Rounds: RoundsMax, MinSha512Rounds: RoundsMin, MaxSha512Rounds: RoundsMax, }
Functions ¶
This section is empty.
Types ¶
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher hashes and verifies crypt(3) style SHA256 and SHA512 passwords.
func New256 ¶
func New256(rounds int, opts *ValidationOpts) *Hasher
New256 creates a new Hasher for SHA-256 with the given rounds and validation options. If rounds == 0, the default rounds value of 5000 is used.
func New512 ¶
func New512(rounds int, opts *ValidationOpts) *Hasher
New512 creates a new Hasher for SHA-512 with the given rounds and validation options. If rounds == 0, the default rounds value of 5000 is used.
type ValidationOpts ¶ added in v0.12.0
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
func NewVerifier ¶ added in v0.12.0
func NewVerifier(opts *ValidationOpts) *Verifier
Click to show internal directories.
Click to hide internal directories.