Documentation
¶
Index ¶
- Constants
- Variables
- func Alpha(n int) string
- func AlphaNumeric(n int) string
- func CreateDerivedKey(password string) (_ string, err error)
- func CryptoRandInt() uint64
- func IsDerivedKey(s string) bool
- func KeyID() string
- func ParseDerivedKey(encoded string) (dk, salt []byte, time, memory uint32, threads uint8, err error)
- func Secret() string
- func Strength(password string) (strength uint8, err error)
- func VerifyDerivedKey(dk, password string) (_ bool, err error)
Constants ¶
const ( KeyIDLength = 22 SecretLength = 48 )
Defaults for the length of key IDs and secrets being generated.
Variables ¶
var ( ErrPasswordEmpty = errors.New("password must not be an empty string") ErrPasswordTooShort = errors.New("password must be at least 8 characters") ErrPasswordWhitespace = errors.New("password must not start or end with whitespace") ErrPasswordStrength = errors.New("password must contain uppercase letters, lowercase letters, numbers, and special characters") )
Password Strength Errors
Functions ¶
func Alpha ¶
Alpha generates a random string of n characters that only includes upper and lowercase letters (no symbols or digits).
func AlphaNumeric ¶
AlphaNumeric generates a random string of n characters that includes upper and lowercase letters and the digits 0-9.
func CreateDerivedKey ¶
CreateDerivedKey creates an encoded derived key with a random hash for the password.
func CryptoRandInt ¶
func CryptoRandInt() uint64
func IsDerivedKey ¶
func KeyID ¶
func KeyID() string
KeyID returns a random ID that is of a fixed length with only alpha characters.
func ParseDerivedKey ¶
func ParseDerivedKey(encoded string) (dk, salt []byte, time, memory uint32, threads uint8, err error)
ParseDerivedKey returns the parts of the encoded derived key string.
func Secret ¶
func Secret() string
Secret returns a random string of a fixed length with alpha-numeric characters.
func Strength ¶
Returns an error if the password is not strong enough as well as a password strength score to compare the strengths of different passwords.
func VerifyDerivedKey ¶
VerifyDerivedKey checks that the submitted password matches the derived key.
Types ¶
This section is empty.