Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

tag: 0.1.8
README.rdoc

pwdcalc

Pwdcalc is a Rails 3 gem to create password field/-strength meter combinations. 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.