Sifar

Sifar can be used to check for strong passwords. Apart from the standard tests for length and homogeneity, it can check passwords that sound and spell similar to a given word.

Sifar can also generate passwords that satisfy the given criteria.

Upgrade Notes

Version 0.2.0 is a complete rewrite. Please check usage before upgrading.

Installation

Requirements

You need the text gem. This is installed automatically if Sifar is installed as a gem. More information on text can be found at github.com/threedaymonk/text.

Sifar has been tested only on *nix systems.

As a gem

Install the gem:

> sudo gem install sifar

To use the Sifar gem with bundler, add the following line in your Gemfile:

gem 'sifar'

As a Rails plugin

To add Sifar as a plugin in a Rails application, run the following command from your application root:

> ./script/plugin install [email protected]:meshbrain/sifar.git

Usage

Validate

require 'sifar'
checker = Sifar.new ...
p checker.errors unless checker.check(word)

Generate

require 'sifar'
checker = Sifar.new ...
password = checker.generate

Checks

Checks can be used separately or in combination.

Minimum length

Password should be at least x characters long.

checker = Sifar.new :minimum_length => 8
checker.check('pword')                        # => false
checker.check('password')                     # => true
checker.check('longpassword')                 # => true

Heterogeneous passwords

Password should contain a mix of digits, uppercase and lowercase characters.

checker = Sifar.new :heterogeneous => true
checker.check('password')                     # => false
checker.check('Pa55w0rD')                     # => true

Dictionary passwords

Password should not contain any word from a given file.

checker = Sifar.new :dictionary => '/path/to/dictionary'
checker.check('indictionary')                 # => false

Reject specific characters

Password should not contain any character from a given set.

checker = Sifar.new :character_blacklist => %w(& % $)
checker.check('pass%word')                    # => false

Passwords that spell similar to a given name

Levenshtein distance of two words should be more than a given threshold. :name is mandatory.

checker = Sifar.new :similarity => 1, :name => 'shoeman'
checker.check('showman')                      # => false
checker.check('anothershowman')               # => false
checker.check('password')                     # => true

Words that sound similar to a given name

Phonetic similarity of two words should be more than a given threshold. :name is mandatory.

checker = Sifar.new :phonetic_similarity => 1, :name => 'suman'
checker.check('showman')                      # => false
checker.check('password')                     # => true

NOTE: This check uses metaphone; and might not work as expected in all languages.

Copyright © 2011 Suman Debnath. See LICENSE for details.