Altpass
A Ruby gem and command-line utility for generating passwords derived from hand-alternating, visually unambiguous, alphanumeric characters.
Example
nXH3ix9w
General Characteristics
- alternates hands (currently only supports
QWERTY
keyboard layout) - always starts with a lower-case character (left-hand first for odd-length passwords; right if even)
- always ends with a left-hand character (so that the right-hand can finalize the hand alternation by hitting
Enter
/Return
) - all characters are alphanumeric; there are no symbols (so the passwords highlight when double-clicked)
- all characters are visually unambigous (some fonts make it difficult/impossible to distinguish zero and capital 'o', or one and lowercase 'L', and uppercase i, etc. so such characters are purposely not used)
The "memorizable" pattern
- the "memorizable" pattern is: lower, UPPER, UPPER, number, lower, lower, number, lower
- this pattern repeats for longer passwords
At a glance, a password such as nXH3ix9w
looks incredibly difficult to memorize, but practicing it 5-10 times usually does the trick, particularly after first taking note of the pattern.
Options
- make passwords of any length (
:length => [0-9]+
) - use the memorizable pattern or not (
:memorizable => true|false
) - show the sample sets and number of permutations (
:permutations => [vvv]
) (morev
's increase verbosity)
Defaults
:length => 8
:memorizable => true
Examples of Gem Usage
Return a default password:
Altpass.generate
=> "uGL4ox7f"
Return an odd-length password, not using the memorizable pattern:
Altpass.generate(:length => 15, :memorizable => false)
=> "cH5L3jwyw9XPw8V"
Return an even-length password, not using the memorizable pattern:
Altpass.generate(:length => 16, :memorizable => false)
=> "uV7AhspqySkBUwhs"
Return the number of permutations:
Altpass.permutations(:length => 16, :memorizable => false)
=> 2869959681148181529600
Print the sample sets and permutation calculation of a default password, and return the number of permutations:
Altpass.permutations(:length => 8, :memorizable => true, :permutations => 'vvv')
sample sets:
["y", "u", "i", "o", "p", "h", "j", "k", "n", "m"]
["Q", "W", "E", "R", "T", "A", "S", "D", "F", "G", "Z", "X", "C", "V", "B"]
["Y", "U", "P", "H", "J", "K", "L", "N", "M"]
["2", "3", "4", "5"]
["y", "u", "i", "o", "p", "h", "j", "k", "n", "m"]
["q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v"]
["7", "8", "9"]
["q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v"]
10 * 15 * 9 * 4 * 10 * 14 * 3 * 14 permutations
=> 31752000
Installation
Add this line to your application's Gemfile:
gem 'altpass'
And then execute:
$ bundle
Or install it yourself:
$ gem install altpass
The Command-Line Utility
The command-line utility, altpass.rb
, is built into the gem.
Example
$ altpass.rb
nF7zHTNrjtYRmxod
Options
Usage: altpass.rb [options]
-l, --length [INTEGER>0] Password length
-m, --memorizable [true|false] Use the memorizable pattern or not
-p, --permutations [vvv] Show permutation size; verbosity increases with v's
-s, --switches Show password switches
-h, --help Show this message
Configuration
Program defaults
The program itself comes with the following defaults:
[:length] = 8
[:memorizable] = true
[:permutations] = false
[:switches] = false
File override
Overrides program defaults.
cat ~/.altpass.yaml
:length: 16
:memorizable: false
Command-line override
Command-line options override everything mentioned above. See Command-line Options above.
Examples of Command-Line Usage
These examples assume the above mentioned Configuration section is in effect.
$ altpass.rb
nF7zHTNrjtYRmxod
$ altpass.rb -p
oDKfhfYznFN3j4Nv
2,869,959,681,148,181,529,600 permutations
$ altpass.rb --length 8 --memorizable true
kSU5yx9e
$ altpass.rb -l8 -mt -pvvv -s
jXJ3oc7z
sample sets:
["y", "u", "i", "o", "p", "h", "j", "k", "n", "m"]
["Q", "W", "E", "R", "T", "A", "S", "D", "F", "G", "Z", "X", "C", "V", "B"]
["Y", "U", "P", "H", "J", "K", "L", "N", "M"]
["2", "3", "4", "5"]
["y", "u", "i", "o", "p", "h", "j", "k", "n", "m"]
["q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v"]
["7", "8", "9"]
["q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v"]
10 * 15 * 9 * 4 * 10 * 14 * 3 * 14 permutations
31,752,000 permutations
--length 8 --memorizable true
Contributing
- Fork it
- 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 new Pull Request