UNPKG

password-analysis

Version:

A library for analyzing the strength of a password

6 lines (5 loc) 209 B
export function calculateEntropy(password: string): number { const uniqueChars = new Set(password).size; const length = password.length; return Math.log2(Math.pow(uniqueChars, length)); }