Dev-Random-Passwords
Passwords that need to be used long term and are randomly generated need more randomness than your standard random library. On Linux, Unix or OSX /dev/random can be used to create really secure passwords from random bytes. This gem provides an implementation to do just that.
Installation
Add this line to your application's Gemfile:
gem 'dev-random-passwords'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dev-random-passwords
Usage
From command line
Simply install the gem and run "randompasswords"
$ randompasswords
dV>28l,T
Use -l to specify chracter length
$ randompasswords -l 16
U[3wjY?]~h$26s!Q
Use -c to set which character types you want to use (uppercase, lowercase, digits or special)
$ randompasswords -l 16 -c lowercase,uppercase
cxtDCjIaTFmHnlba
Use -i to include certain characters or -e to exclude them
$ randompasswords -c digits -l 54 -e 23456789
010000101100100111000010000111101010011101110010011011
Run "randompasswords -h" for full set of options and description
For programming
Require the gem
require 'dev-random-passwords'
Set up a new instance
rpg = DevRandomPasswords::Generator.new
Set some options for your password
rpg.({'lowercase' => true, 'uppercase' => true, 'digits' => true, 'length' => 12, 'requirements' => {'digits' => true, 'uppercase' => true, 'lowercase' => true}})
Generate a new password
rpg.generate #=> "J0jhBM9dAPwk"
Enjoy!
Contributing
- Fork it ( https://github.com/jbsmith86/dev-random-passwords/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request