4 ms·
I think this is the function from the LastPass source code that's calculating the password strength: var p = function(b, f) { var a = 0; if
by a_puppy 10y ago
I think this is the function from the LastPass source code that's calculating the password strength:
var p = function(b, f) {
var a = 0;
if ("" === f && "" === b)
return 0;
var c = b.toLowerCase()
, d = f.toLowerCase();
if (c === d || d && -1 !== c.indexOf(d) || d && -1 !== d.indexOf(c))
return 1;
a += b.length;
if (0 < b.length && 7 >= b.length)
return 1;
8 <= b.length && 15 >= b.length ? a += 12 : 16 <= b.length && (a += 18);
b.match(/[a-z]/) && (a += 1);
b.match(/[A-Z]/) && (a += 5);
b.match(/\d/) && (a += 5);
b.match(/.*\d.*\d.*\d/) && (a += 5);
b.match(/[!,@,#,$,%,^,&,*,?,_,~]/) && (a += 5);
b.match(/.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~]/) && (a += 5);
b.match(/(?=.*[a-z])(?=.*[A-Z])/) && (a += 2);
b.match(/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/) && (a += 2);
b.match(/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!,@,#,$,%,^,&,*,?,_,~])/) && (a += 2);
for (var c = {}, e = d = 0, n = b.length; e < n; ++e) {
var l = b.charAt(e);
void 0 === c[l] && (c[l] = 1,
++d)
}
if (1 === d)
return 2;
a *= 2;
0 > a ? a = 0 : 100 < a && (a = 100);
return a
}
I think "b" is the password and I'm guessing that "f" is the username.