UNPKG
password-analysis
Version:
latest (1.0.1)
1.0.1
1.0.0
A library for analyzing the strength of a password
password-analysis
/
src
/
entropy.ts
6 lines
(5 loc)
•
209 B
text/typescript
View Raw
1
2
3
4
5
6
export
function
calculateEntropy
(
password
:
string
):
number
{
const
uniqueChars =
new
Set
(password).
size
;
const
length = password.
length
;
return
Math
.
log2
(
Math
.
pow
(uniqueChars, length)); }