Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password Strength Meter [closed]

I have a situation where I would like to be able to rate a users password in the web interface to my system, so that before they hit submit they know if they have a bad password.

Key Requirements:

  • Must be able to rate the password, not just pass/fail.
  • Should disable the form if the password is below a threshhold, so the user can't submit it.
  • Look nice. :)
  • Not use jQuery - we're currently using Mochikit and Y!UI in this system.

I've found many password meters written in jQuery, and things like http://www.passwordmeter.com/ that are too verbose.

Can anyone suggest a good drop in javascript password rater I can use, or give an example of how to write one?

like image 705
Jerub Avatar asked Jun 04 '09 01:06

Jerub


People also ask

How long does it take to crack a password?

The findings suggest that even an eight-character password — with a healthy mix of numbers, uppercase letters, lowercase letters and symbols — can be cracked within eight hours by the average hacker.

What is password strength meter?

Password Meter - A visual assessment of password strengths and weaknesses.

How do I disable password strength meter in Wordpress?

Navigate under the tab “Options” and the sub-navigation menu “General” to toggle on the section “Disable Password Strength Meter”.

Is the password meter safe?

So, password meters are not a reliable guide to how likely it is that your password will be cracked but they do seem to nudge people in the direction of creating stronger passwords in general.


1 Answers

Update: created a js fiddle here to see it live: http://jsfiddle.net/HFMvX/

I went through tons of google searches and didn't find anything satisfying. i like how passpack have done it so essentially reverse-engineered their approach, here we go:

function scorePassword(pass) {     var score = 0;     if (!pass)         return score;      // award every unique letter until 5 repetitions     var letters = new Object();     for (var i=0; i<pass.length; i++) {         letters[pass[i]] = (letters[pass[i]] || 0) + 1;         score += 5.0 / letters[pass[i]];     }      // bonus points for mixing it up     var variations = {         digits: /\d/.test(pass),         lower: /[a-z]/.test(pass),         upper: /[A-Z]/.test(pass),         nonWords: /\W/.test(pass),     }      var variationCount = 0;     for (var check in variations) {         variationCount += (variations[check] == true) ? 1 : 0;     }     score += (variationCount - 1) * 10;      return parseInt(score); } 

Good passwords start to score around 60 or so, here's function to translate that in words:

function checkPassStrength(pass) {     var score = scorePassword(pass);     if (score > 80)         return "strong";     if (score > 60)         return "good";     if (score >= 30)         return "weak";      return ""; } 

you might want to tune this a bit but i found it working for me nicely

like image 181
tm_lv Avatar answered Oct 12 '22 22:10

tm_lv