Documentation ¶
Index ¶
- Constants
- func CheckSum(message []byte) []byte
- func Decrypt(key, message []byte) ([]byte, error)
- func DefaultPasswordCharRange() []uint8
- func Encrypt(key, message []byte) ([]byte, error)
- func GeneratePassword(length int, characters []uint8) string
- func GenerateRandomBytes(len uint32) []byte
- func GenerateSalt() []byte
- func GetPasswordCharRange(passwordStrength PasswordStrength) (charRange []uint8)
- func Hmac(key, message []byte) []byte
- func PasswordHash(password string, salt []byte, threads uint8) []byte
- func VerifyHmac(mac1, mac2 []byte) bool
- type PasswordStrength
Constants ¶
View Source
const ( // TIME complexity parameter for Argon2, used by PasswordHash. TIME uint32 = 8 // MEMORY complexity parameter for Argon2, used by PasswordHash. MEMORY uint32 = 32 * 1024 // SALTLEN length of salt given by GenerateSalt. SALTLEN uint32 = 32 // KEYLEN length of key generated by PasswordHash. KEYLEN uint32 = 32 // 32-bytes keys are used with AES-256 )
Variables ¶
This section is empty.
Functions ¶
func DefaultPasswordCharRange ¶
func DefaultPasswordCharRange() []uint8
DefaultPasswordCharRange returns the default ASCII characters to be used with GeneratePassword().
func GeneratePassword ¶
GeneratePassword generates a random sequence of the given ASCII characters.
func GenerateRandomBytes ¶
GenerateRandomBytes generates a random sequence of bytes.
func GenerateSalt ¶
func GenerateSalt() []byte
GenerateSalt generates a random sequence of bytes that can be used as a password salt.
func GetPasswordCharRange ¶
func GetPasswordCharRange(passwordStrength PasswordStrength) (charRange []uint8)
GetPasswordCharRange returns the appropriate char-range for the given PasswordStrength.
func PasswordHash ¶
PasswordHash creates a cryptographical hash of the salted password.
func VerifyHmac ¶
VerifyHmac verifies the two given HMAC's are equal. Returns true if equal, false otherwise.
Types ¶
type PasswordStrength ¶
type PasswordStrength int
PasswordStrength specifies the desired strength of a password generated with GeneratePassword.
const ( // WEAK policy includes only standard latin alphabet characters. WEAK PasswordStrength = iota + 1 // ALPHANUMERIC policy includes all alphanumeric characters. ALPHANUMERIC // NORMAL policy includes alphanumeric characters plus standard ASCII symbols. NORMAL // STRONG policy includes extended ASCII characters and standard ASCII symbols. STRONG // STRONGEST policy includes extended ASCII characters and extended ASCII symbols. STRONGEST )
Click to show internal directories.
Click to hide internal directories.