Created
February 18, 2009 12:09
-
-
Save kdwinter/66309 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 | |
module PwGen | |
class Password | |
include Enumerable | |
attr_reader :vwl, :con, :num | |
$timestamp = Time.now.strftime("%Y %m %d %T") | |
def initialize(size=6, nums=2) | |
$size, $nums = size, nums | |
@vwl = ['a', 'e', 'i', 'o', 'u'] | |
@con = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'y', 'z'] | |
@num = ('0'..'9').to_a | |
@newpass = '' | |
end | |
def generate | |
1.upto($size) do |i| | |
if i % 2 == 0 | |
@newpass << @vwl[rand(@vwl.size-1)] | |
else | |
@newpass << @con[rand(@con.size-1)] | |
end | |
end | |
1.upto($nums) do |a| | |
@newpass << @num[rand(@num.size-1)] | |
end | |
@newpass | |
end | |
end | |
def self.run | |
puts " : Generated : #{$timestamp} for user #{ENV['USER']}" | |
puts " : Passphrase : #{Password.new(6, 2).generate}" | |
puts "\n\n" | |
puts 'WARNING: Your scrollback buffer contains this passphrase, please nuke this term' | |
end | |
end | |
PwGen::run if $0 == __FILE__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment