Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 4x 4x 2x 2x 2x 4x 2x 2x 2x 2x 2x 2x 2x 4x 4x 2x 2x | const BREAKPOINTS = [ 78.0, 52, 0 ];
const PWSTRENGTH_LABELS = [ 'weak', 'acceptable', 'strong' ];
function passwordcheck (pw) {
const pwEntropy = blindEntropy(pw);
const strength = entropyMeter(pwEntropy);
return {
strength,
label: PWSTRENGTH_LABELS[strength]
};
}
const blindEntropy = (pw) => {
const numberPermutations = /.*[0-9].*/.test(pw) ? 10 : 0;
const lowercasePermutations = /.*[a-z].*/.test(pw) ? 26 : 0;
const uppercasePermutations = /.*[A-Z].*/.test(pw) ? 26 : 0;
const punctuationPermutations = /.*[^a-zA-Z0-9].*/.test(pw) ? 33 : 0;
const permutations = numberPermutations + lowercasePermutations + uppercasePermutations + punctuationPermutations;
const pwLength = pw.length;
return Math.log2(permutations ** pwLength);
};
const entropyMeter = (pwEntropy) => {
const ndx = BREAKPOINTS.findIndex(e => pwEntropy >= e);
// 0 = Too Weak; 1 == Acceptable; 2 = Strong
const strength = BREAKPOINTS.length - 1 - ndx;
return strength;
};
export default passwordcheck;
|