Generate passwords using KeePass password generator patterns
Go to file
John Nishinaga 996cc2b1d4 added author
2011-03-22 09:13:07 -04:00
lib reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
spec reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
.gitignore reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
.rspec reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
.yardopts reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
CHANGELOG.md reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
Gemfile reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
keepass-password-generator.gemspec reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
MIT-LICENSE.txt added author 2011-03-22 09:13:07 -04:00
Rakefile reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00
README.md reset repository with new author information, license and version 2011-03-22 09:11:41 -04:00

keepass-password-generator

Generate passwords using KeePass password generator patterns.

RubyGems installation

gem install keepass-password-generator

Bundler installation

In your Gemfile:

gem 'keepass-password-generator'

Install bundled gems:

bundle

Usage

require 'keepass/password'

KeePass::Password.generate('A{6}s')
#=> "Un2hd#t"

See http://keepass.info/help/base/pwgenerator.html for information about KeePass patterns.

Examples

A 40-bit WEP key:

KeePass::Password.generate('h{10}')
#=> "ae6929dc0e"

A random MAC address:

KeePass::Password.generate('HH\-HH\-HH\-HH\-HH\-HH', :permute => false)
#=> "0D-4D-32-64-EB-7D"

A password with 10 alphanumeric characters, where at least 2 are upper case and at least are 2 lower case characters:

KeePass::Password.generate('uullA{6}')
#=> "us2j1nTIQT"

A password with 20 alphanumeric and symbol characters, without any lookalike characters (e.g., I and |):

KeePass::Password.generate('[As]{20}', :remove_lookalikes => true)
#=> "-2~[+Rze{hZezk(\\nZ-W"

Invalid patterns raise an exception:

KeePass::Password.generate('[\I\|]{3}', :remove_lookalikes => true)
#=> KeePass::Password::InvalidPatternError: empty character set for token 1 for "[\\I\\|]{3}"