Created
February 18, 2009 14:58
-
-
Save kdwinter/66371 to your computer and use it in GitHub Desktop.
This file contains 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 | |
=begin | |
Author: Gigamo <gigamo@gmail.com> | |
This script generates a passphrase consisting of <size> letters in the start | |
and <nums> numbers in the end. Every even size it will use a vowel, uneven | |
will use a consonant. | |
=end | |
class Password | |
def self.run | |
$timestamp = Time.now.strftime("%Y %b %d %T") | |
$passphrase = generate 6, 2 | |
puts " : Generated : #{$timestamp} for user #{ENV['USER']}" | |
puts " : Passphrase : #{$passphrase}" | |
puts "\n\n" | |
puts 'WARNING: Your scrollback buffer contains this passphrase, please nuke this term' | |
end | |
private | |
include Enumerable | |
@vwl = %w(a e i o u) | |
@con = %w(b c d f g h j k l m n p r s t v w y z) | |
@num = %w(0 1 2 3 4 5 6 7 8 9) | |
def self.generate(size=6, nums=2) | |
@newpass = '' | |
1.upto(size) do |i| | |
i % 2 == 0 ? @newpass << @vwl[rand(@vwl.size-1)] : @newpass << @con[rand(@con.size-1)] | |
end | |
1.upto(nums) do |a| | |
@newpass << @num[rand(@num.size-1)] | |
end | |
@newpass | |
end | |
end | |
Password.run if $0 == __FILE__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment