MCPcopy Create free account
hub / github.com/danpalmer/jquery.complexify.js / evaluateSecurity

Function evaluateSecurity

jquery.complexify.js:151–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149 }
150
151 function evaluateSecurity() {
152 var password = $(this).val();
153 var complexity = 0, valid = false;
154
155 // Reset complexity to 0 when banned password is found
156 if (!inBanlist(password)) {
157
158 // Add character complexity
159 for (var i = CHARSETS.length - 1; i >= 0; i--) {
160 complexity += additionalComplexityForCharset(password, CHARSETS[i]);
161 }
162
163 } else {
164 complexity = 1;
165 }
166
167 // Use natural log to produce linear scale
168 complexity = Math.log(Math.pow(complexity, password.length)) * (1/options.strengthScaleFactor);
169
170 valid = (complexity > MIN_COMPLEXITY && password.length >= options.minimumChars);
171
172 // Scale to percentage, so it can be used for a progress bar
173 complexity = (complexity / MAX_COMPLEXITY) * 100;
174 complexity = (complexity > 100) ? 100 : complexity;
175
176 callback.call(this, valid, complexity);
177 }
178
179 this.each(function () {
180 if($(this).val()) {

Callers

nothing calls this directly

Calls 2

inBanlistFunction · 0.85

Tested by

no test coverage detected