information-entropy
Calculate the required length or the entropy of a password. Inspired by the following Wikipedia article on password strength.
The result of these calculations assumes that the password generator uses a truly random selection process, where each symbol is randomly drawn from the set.
usage
const calculateEntropy calculateLength = const symbolSets = hexadecimalNumerals: 16 asciiPrintableCharacters: 95 custom: `a` `b` 2 const passwordLength = 24// 96 const entropy = 128// 20// 81
api
calculateEntropy(symbolSet, passwordLength)
Returns the entropy in bits.
symbolSet
and passwordLength
can be anything with a .length
property or a number denoting a length.
calculateLength(symbolSet, bitsOfEntropy)
Returns the required number of random selections from the set.
symbolSet
can be anything with a .length
property or a number denoting a size. bitsOfEntropy
must be a number.