Created
August 5, 2021 11:39
-
-
Save terefang/ed4ddba52064d335167045451fb96e4b to your computer and use it in GitHub Desktop.
javascript strength pw check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* pw strong > 3096 */ | |
function check_password_safety(_pwtocheck) | |
{ | |
var _bits = 0; | |
var _len = _pwtocheck.length; | |
for(var _i=0; _i<_pwtocheck.length; _i++) | |
{ | |
var _code = _pwtocheck.charCodeAt(_i); | |
var _chr = _pwtocheck.charAt(_i); | |
var _c = Math.log2(Math.max(1,_code-31))*Math.PI*Math.PI*Math.PI; | |
_bits |= _c; | |
if(_i==0) continue; | |
if(_i==_pwtocheck.length-1) continue; | |
var _li = _pwtocheck.lastIndexOf(_chr,_i-1); | |
if(_li!=-1 && Math.abs(_li-_i)<2) _len--; | |
var _la = _pwtocheck.indexOf(_chr,_i+1); | |
if(_la!=-1 && Math.abs(_la-_i-1)<2) _len--; | |
} | |
return (_len*_bits); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment