Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Take no risk and help your users to choose good passwords!
Ruby CoffeeScript JavaScript CSS
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app/assets
lib
spec
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile
pwdcalc.gemspec

README.rdoc

pwdcalc

Improve the user experience and security of your web application within just a few seconds by installing the pwdcalc gem: display a password strength meter on your sign up form.

Take no risk and help your users to choose good passwords!

Formtastic and SimpleForm are both supported!

Installation

Add pwdcalc to your Gemfile and bundle it up:

gem 'pwdcalc'

Run the installation generator:

rails g pwdcalc:install

JavaScript

Rails < 3.1

Add the following asset tag to the <head> section of your layout:

<%= javascript_include_tag "jquery.YAPSM.min", "jquery.pwdcalc" %>

Rails >= 3.1

Add the following directives to your JavaScript manifest file:

//= require jquery.YAPSM.min
//= require jquery.pwdcalc

Stylesheets

Rails < 3.1

Add the following asset tag to the <head> section of your layout:

<%= stylesheet_link_tag "formtastic", "pwdcalc" %>

Rails >= 3.1

Add the following directives to your CSS manifest file:

*= require formtastic
*= require pwdcalc

Usage

To create a password field/-strength meter combination, simply put the following line in your form:

Using Formtastic

<%= form.input :password, :as => :pwdcalc %>

Using SimpleForm

<%= form.input :password, :as => :pwdcalc_simple %>

That's it!

Localized Hints

Add the following line somewhere inside your view (e.g. at the bottom of your page):

<%= pwdcalc_hints %>

Dictionary Attacks

Many people have a tendency to choose passwords which are short, single words found in dictionaries or simple, easily-predicted variations on words, vulnerable for dictionary attacks.

It's easy to provide a list of obvious passwords. Just add the data-dictionary attribute to the input field:

<%= form.input :password, :as => :pwdcalc, :'data-dictionary' => 'obviousPasswords()' %>

Keep in mind that the value should evaluate to an array.

Events

$(document).bind('pwdcalc-submit', handler(eventObject, origEventObject, field))

The pwdcalc-submit event is sent to the document when the user is attempting to submit the form.

$(document).bind('pwdcalc-keyup-init', handler(eventObject, origEventObject, field))

The pwdcalc-keyup-init event is sent to the document when the user releases a key on the keyboard and before a score and hint is shown or hidden.

$(document).bind('pwdcalc-keyup-complete', handler(eventObject, origEventObject, field))

The pwdcalc-keyup-complete event is sent to the document when the user releases a key on the keyboard and after a score and hint is shown or hidden.

YAPSM (Yet Another Password Strength Meter)

The project page of this jQuery plugin can be found here on GitHub!

Bug Tracker

Have a bug? Please create an issue here on GitHub!

github.com/trimentor/pwdcalc/issues

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history.

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2012 Kjel Delaey, released under the MIT license.

Something went wrong with that request. Please try again.