= Introduction Validates the strength of a password according to several rules: * size * 3+ numbers * 2+ special characters * uppercased and downcased letters * combination of numbers, letters and symbols * password contains username * sequences (123, abc, aaa) Some results: * 123: weak * 123abc: weak * aaaaaa: weak * myPass145: good * myPass145$: strong = Install sudo gem install password_strength If you want the source go to http://github.com/fnando/password_strength = Usage strength = PasswordStrength.test("johndoe", "mypass") #=> return a object strength.good? #=> status == :good strength.weak? #=> status == :weak strength.strong? #=> status == :strong strength.status #=> can be :weak, :good, :strong strength.valid?(:strong) #=> strength == :strong strength.valid?(:good) #=> strength == :good or strength == :strong = ActiveRecord The PasswordStrength library comes with ActiveRecord support (tested on AR 2.3.5 and 3.0.0-beta). class Person < ActiveRecord::Base validates_strength_of :password end The default options are :level => :good, :with => :username. If you want to compare your password against other field, you have to set the :with option. validates_strength_of :password, :with => :email The available levels are: :weak, :good and :strong = JavaScript The PasswordStrength also implements the algorithm in the JavaScript. var strength = PasswordStrength.test("johndoe", "mypass"); strength.isGood(); strength.isStrong(); strength.isWeak(); strength.isValid("good"); The API is basically the same! Get the file: http://github.com/fnando/password_strength/raw/master/lib/password_strength.js = TO-DO * Detect repetitions * Rake task to get the latest JavaScript file = License (The MIT License) Copyright © 2010: * Nando Vieira (http://simplesideias.com.br) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.