Documentation
¶
Index ¶
- Constants
- func GenerateSalt(length int) ([]byte, error)
- func HashPasswordV2(password, salt []byte) []byte
- func HashPasswordV3(password, salt []byte, algorithm HashAlgorithm, iterations, numBytes int) []byte
- func Verify(hashedPassword, clearPassword []byte) bool
- func VerifyPasswordV2(hashedPassword, clearPassword []byte) bool
- func VerifyPasswordV3(hashedPassword, clearPassword []byte) bool
- type HashAlgorithm
Constants ¶
View Source
const ( // DefaultSaltLength is the default salt length for new passwords DefaultSaltLength = 16 // DefaultIterations is the default number of iterations for new passwords DefaultIterations = 10000 // DefaultHashAlgorithm is the default hashing algorithm for new passwords DefaultHashAlgorithm = SHA256 // DefaultNumBytes is the default number of bytes reserved for the subkey DefaultNumBytes = 32 )
Variables ¶
This section is empty.
Functions ¶
func GenerateSalt ¶
GenerateSalt generates a cryptographically safe random salt of the specified length
func HashPasswordV2 ¶
func HashPasswordV3 ¶
func HashPasswordV3(password, salt []byte, algorithm HashAlgorithm, iterations, numBytes int) []byte
HashPasswordV3 hashes the given password with the specified salt, algorithm, number of iterations and hash length
func VerifyPasswordV2 ¶
func VerifyPasswordV3 ¶
VerifyPasswordV3 verifies the given hashed password against the given clear text password and returns true if they match
Types ¶
type HashAlgorithm ¶
type HashAlgorithm uint32
HashAlgorithm represents the hashing algorithm used to hash the password
const ( SHA1 HashAlgorithm = iota SHA256 SHA512 )
Click to show internal directories.
Click to hide internal directories.