Skip to content

Instantly share code, notes, and snippets.

@kdwinter
Created February 18, 2009 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdwinter/66316 to your computer and use it in GitHub Desktop.
Save kdwinter/66316 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
module PwGeneRB
module PasswordGenerator
class Password
include Enumerable
$timestamp = Time.now.strftime("%Y %b %d %T")
@chars = ('a'..'z').to_a + ('0'..'9').to_a
@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)
@newpass = ''
def self.generate(size=6, nums=2)
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
end
module Encrypt
class EncryptPassword < PasswordGenerator::Password
end
end
def self.run
puts " : Generated : #{$timestamp} for user #{ENV['USER']}"
puts " : Passphrase : #{PasswordGenerator::Password.generate 6, 2}"
puts "\n\n"
puts 'WARNING: Your scrollback buffer contains this passphrase, please nuke this term'
end
end
PwGeneRB::run if $0 == __FILE__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment