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
/
dist
/
entropy.js
9 lines
(8 loc)
•
299 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
"use strict"
;
Object
.
defineProperty
(
exports
,
"__esModule"
, {
value
:
true
});
exports
.
calculateEntropy
= calculateEntropy;
function
calculateEntropy
(
password
) {
const
uniqueChars =
new
Set
(password).
size
;
const
length = password.
length
;
return
Math
.
log2
(
Math
.
pow
(uniqueChars, length)); }