passwords

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyIDLength  = 22
	SecretLength = 48
)

Defaults for the length of key IDs and secrets being generated.

Variables

View Source
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

func Alpha(n int) string

Alpha generates a random string of n characters that only includes upper and lowercase letters (no symbols or digits).

func AlphaNumeric

func AlphaNumeric(n int) string

AlphaNumeric generates a random string of n characters that includes upper and lowercase letters and the digits 0-9.

func CreateDerivedKey

func CreateDerivedKey(password string) (_ string, err error)

CreateDerivedKey creates an encoded derived key with a random hash for the password.

func CryptoRandInt

func CryptoRandInt() uint64

func IsDerivedKey

func IsDerivedKey(s string) bool

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

func Strength(password string) (strength uint8, err error)

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

func VerifyDerivedKey(dk, password string) (_ bool, err error)

VerifyDerivedKey checks that the submitted password matches the derived key.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL