Skip to content
A library to generate strong passwords and check password strength.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



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.



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

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



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


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


Checks can be used separately or in combination.

Minimum length

Password should be at least x characters long.

checker = :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 = :heterogeneous => true
checker.check('password')                     # => false
checker.check('Pa55w0rD')                     # => true

Dictionary passwords

Password should not contain any word from a given file.

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

Reject specific characters

Password should not contain any character from a given set.

checker = :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 = :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 = :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.

You can’t perform that action at this time.