Created
December 19, 2017 16:14
-
-
Save bagilevi/4523cc4a9cf057ffb2c8e02a73aacf52 to your computer and use it in GitHub Desktop.
password generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| lens = Array(ARGV[0]&.to_i || [20, 16, 10, 8, 6]) | |
| lo = 'qwertuiopasdfghjkxcvbnm'.split('') | |
| up = 'QWERTUPASDFGHJKLXCVBNM'.split('') | |
| nu = '123456789'.split('') | |
| si = '!@#$%^&*()-=+[]{};\'\\:"|,./<>?'.split('') | |
| lens.each do |len| | |
| puts [ | |
| ([ si.sample, nu.sample, up.sample, up.sample ] + (len - 4).times.map { lo.sample }).shuffle.join, | |
| ([ nu.sample, nu.sample, up.sample, up.sample ] + (len - 4).times.map { lo.sample }).shuffle.join, | |
| len.times.map { lo.sample }.shuffle.join | |
| ].join(' ') | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment