Password Strength Meter (a jquery plugin)

Password Strength Meter is a jQuery plug-in provide you smart algorithm to detect a password strength.

The Password strength procedure is working as the follow:
We have many cases to care about to know a password strength , so we will present a global variable score , and each case will add some points to score.
At the end of the algorithm we will decide the password strength according to the score value.
The cases we have are :

  • If the password matches the username then BadPassword
  • If the password is less than 4 characters then TooShortPassword
  • Score += password length * 4
  • Score -= repeated characters in the password ( 1 char repetition )
  • Score -= repeated characters in the password ( 2 char repetition )
  • Score -= repeated characters in the password ( 3 char repetition )
  • Score -= repeated characters in the password ( 4 char repetition )
  • If the password has 3 numbers then score += 5
  • If the password has 2 special characters then score += 5
  • If the password has upper and lower character then score += 10
  • If the password has numbers and characters then score += 15
  • If the password has numbers and special characters then score += 15
  • If the password has special characters and characters then score += 15
  • If the password is only characters then score -= 10
  • If the password is only numbers then score -= 10
  • If score > 100 then score = 100

Now according to score we are going to decide the password strength

  • If 0 < score < 34 then BadPassword
  • If 34 < score < 68 then GoodPassword
  • If 68 < score < 100 then StrongPassword

Online demo.
PasswordStrengthMeter.zip

42 Comments so far

  1. jss on May 9, 07

    in the code, it has 1000 instead of 100.

  2. phiras on May 9, 07

    Allright, It’s ok now.
    thank you :)

  3. karam on May 28, 07

    are you phiras

  4. Glen Lipka on June 1, 07

    Wow, nice plugin. One suggestion. You might want to make a demo with a graphic visualization of the strength. Microsoft and Google both do this. Like red 50px bar for weak, yellow 100px for medium, 150px green for strong. I think this is doable right out of the box, but it makes for a compelling demo.

    Again, awesome work!

  5. phiras on June 1, 07

    Thank you Glen,Nice idea :) .
    I’ll work on this soon .

  6. [...] using this code by Phiras. Thank you Phiras for making it available! I’m going to integrate this into WPMU [...]

  7. [...] he visto en Phiras’s Blog, y se trata de una función que nos devolverá el tipo de contraseña que estamos [...]

  8. jd2718 on June 7, 07

    is there any way to distinguish between random letters and words, or does the distinction make no difference as far as password strength?

    IOW, is HbeqqpTvnmlzdn any better than StrongPassword as a password?

  9. Jan on June 7, 07

    “HbeqqpTvnmlzdn” is WAY better than “StrongPassword”, as the first one would require an exhaustive brute-force attack, while the latter one could be broken with a simple dictionary attack. Ignoring the case (to simplify the calculation), the first would need an average of 3*(10^19) operations, while the latter would be broken for sure after 1.5*(10^13) operations using an extremely large dictionary and 100 billion attempts using a small dictionary. That means, the first one would need AT LEAST about 2 billion times the time to break compared to the first one. As dictionary attacks are the only thing anyone might even consider trying against a web application, the first password would be unbreakable, while the second one would give the attacker a slight chance. However, if the attacker managed to test 10 passwords per second using a small dictioary of 10000 words, the probability that he manages to beak the password within a week is 6% - and the wordpress admin team should notice someone hammering their server with 10 wrong auth requests per second within less than a week.

    Additionally, the “password strength meter” considers “0123456789″ to be a good password. In reality, a dictionary attack would break it within quite a short time (I think about 20000 attempts at max.)

    If anyone wants to hack some blogs, he is going to do a simple dictionary attack, without going for passwords consisting of two words, so nearly ANY password not in a password cracking dictionary (qwertz, 123456, asdf and similar things ARE in such dictionaries) will protect you. If anyone wants to hack exactly YOUR block, he WILL infect your pc with a trojan and steal the password or sniff it from a network you use, and then even a password like f”gh&&sah/svSD13″bjh+§#gHW23= is not going to help you.

  10. [...] believe that this is highly relevant for ALL bloggers. I could not find a WordPress plugin for the password strength meter without JQuery but that would be a very useful tool to have. Remember, the weakest link in our [...]

  11. phiras on June 8, 07

    hmm , in fact this is a simple solution (My work) , If we want to handle more complicated cases we need to do it on the server-side because we are going to use a dictionary and another detection approaches.
    We can’t do a lot of work to detect the password strength on the client browser (fully client script) , and I’m working to improve it as possible

  12. [...] ported the jQuery Password Strength Meter from JavaScript to [...]

  13. [...] to measure password strength. He gives points to certains characteristics of the password. Here’s the link. Worth a look. Posted by dante regis Filed in [...]

  14. [...] Strength is a stand-alone port of the WordPress.com feature written by Donncha1 and uses the same Password Strength Meter jQuery goodness, written by [...]

  15. David Bradley on June 15, 07

    I’ve mention the following idea elsewhere, but if you are having trouble thinking of decent passwords that you can remember, check out my passwords for scientists concept.

    http://www.sciencetext.com/passwords-for-scientists.html

    Dave B

  16. [...] believe that this is highly relevant for ALL bloggers. I could not find a WordPress plugin for the password strength meter without JQuery but that would be a very useful tool to have. Remember, the weakest link in our [...]

  17. [...] ha usado este código de Phiras, usuario de wordpress.com, que es un plugin para jQuery. Una solución elegante para recordar la [...]

  18. Zheileman on June 20, 07

    One suggestion:

    If the password *contains* the username (it’s no important the position), it’s going to be a bad password.
    Example:
    for username = paquito
    bad passwords = paquito1 / 1paquito / 1paquito1 / paquitopaquito

  19. Yash on June 21, 07

    great script…thank you

  20. Gasten on June 26, 07

    Is the number of similar characters really that important? isn’t it just the combination of letters that do the trick? (Of cause, ‘aaaaaaaa’ is not a good password, but ‘bl0k0t0′ is pretty strong, no?

  21. [...] Password Strength Meter está diseñado para medir la fortaleza de nuestras contraseñas, ideal para un sistema de altas. [...]

  22. Ronda on August 9, 07

    Thanks a load! Very helpful!

  23. Yearby on September 6, 07
  24. Janis on September 13, 07

    I’m trying to use your password strength meter code but I don’t need the HTML file to be named “Index.html”. When I changed it’s name it no longer worked. I edited the 2 js programs and cannot find where the name is referenced. How can I still make this work? Thank you.

  25. Janis on September 13, 07

    Actually I just changed the name back to Index.html and ftp’d it over and brought it up on the browser and it still doesn’t work. The 2 js files are on the web server too in the same root folder. What am I doing wrong?

  26. Marco on December 9, 07

    password_1 is a strong password; excellent. My credit card is secure.
    Seriously though, great program.

  27. Idetrorce on December 15, 07

    very interesting, but I don’t agree with you
    Idetrorce

  28. Alessandro Ronchi on December 23, 07

    It could be useful to don’t let users use bad passwords in registrations, not only advise them.

    Is it possible?

  29. phiras on December 31, 07

    Yes it’s possible, you should use the algorithm in a different logic.

  30. Andrey Grigorov on January 3, 08

    There are comments

    // checkRepetition(1,’aaaaaaabcbc’ ;) = ‘abcbc’
    // checkRepetition(2,’aaaaaaabcbc’ ;) = ‘aabc’
    // checkRepetition(2,’aaaaaaabcdbcd’ ;) = ‘aabcd’

    in passwordStrengthMeter.js.

    But after execution checkRepetition return
    abcbc
    aaabc
    aaabcdbcd

    Is it mistake? What can this function do?

  31. phiras on January 3, 08

    Yes there is a mistake in this function,

    will be fixed soon.

  32. mark on January 25, 08

    Yeah, work on a visual password strength display too.

  33. iPhone on February 18, 08

    is it working with J2EE ?

  34. Wallpapers iPhone on March 2, 08

    Yep, working

  35. [...] bukan wordpress.com alias wordpress.org bisa mendapatkan pluginnya di sini. Tulisan ini terinspirasi oleh ini, itu dan inu. Ditulis oleh [...]

  36. Blogono Wordpress-MU on March 3, 08

    nice passwords strength tips, keep on with the good posts!

  37. Prix iPhone on March 4, 08

    Nice blog, keep on going !

  38. test on March 18, 08

    1234567891011121314 = strong

    Will be broken in a matter of minutes.

    Brilliant ideas flowing here, keep it up.

  39. phiras on March 18, 08

    1234567891011121314 is a 19 character consist of digits only (9 options for each character), not following a clear pattern , this means : the probabilty to get this password is : 1/9^19 (1/1350851717672992089).

    I don’t think there is any algorithm could break it in minutes ;)

  40. [...] JQuery Password Strength Meter - Password Strength Meter is a jQuery plug-in that provides a smart algorithm to detect a passwords strength. The Password strength works on a point structure that if you pass a certain test than more points will be added and in turn your password will be more secure. [...]

  41. Brad Landis on April 1, 08

    I moved your algorithm over to Python for a project I’m doing, and I noticed that the password “abc123″ got through as “good”, but was actually an early one that was cracked using John the Ripper. I don’t know if there’s any way to check for patterns (alphabetic, numeric, keyboard), but it does make the password a lot weaker when a pattern is present.

    Overall, I’d say your algorithm looks great. Thanks for putting it here.

  42. Brad Landis on April 1, 08

    I came up with a partial solution to finding patterns.

    I subtracted 3 points for every character that is one character away from the previous in the password (using the ord function in Python).

    Keyboard patterns is kind of hard, but I figure “qwer” (followed by “ty” most of the time) and “asdf” are more common than anything else as a keyboard pattern, so I simply searched for those two strings, and subtracted 10 if they were found.

Leave a reply