package entropy

import "git.sr.ht/~seirdy/moac/entropy"

Package entropy provides a means to compute entropy of a given random string by analyzing both the charsets used and its length.

Index

Variables

var Charsets = map[string][]rune{
	"lowercase":      []rune(lowercase),
	"uppercase":      []rune(uppercase),
	"numbers":        []rune(numbers),
	"symbols":        []rune(symbols),
	"latin1":         []rune(latin1),
	"latinExtendedA": []rune(latinExtendedA),
	"latinExtendedB": []rune(latinExtendedB),
	"ipaExtensions":  []rune(ipaExtensions),
}

Charsets is a dictionary of known Unicode code blocks to use when generating passwords. All runes are printable and single-width.

var (
	ErrPasswordInvalid = errors.New("invalid password")
)

A valid password is impossible with the given constraints.

Functions

func Entropy

func Entropy(password string) (float64, error)

Entropy computes the number of entropy bits in the given password, assumingly it was randomly generated.

func FromCharsets

func FromCharsets(charsetsUsed *[][]rune, length int) (float64, error)

FromCharsets computes the number of entropy bits in a string with the given length that utilizes at least one character from each of the given charsets. It does not perform any subsetting/de-duplication upon the given charsets; they are just used as-is.

Source Files

entropy.go

Version
v1.2.0 (latest)
Published
Sep 23, 2021
Platform
linux/amd64
Imports
5 packages
Last checked
1 month ago

Tools for package owners.