Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created December 17, 2010 18:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcromartie/745446 to your computer and use it in GitHub Desktop.
Save jcromartie/745446 to your computer and use it in GitHub Desktop.
Print a random password tabula recta
# by John Cromartie
# idea from http://blog.jgc.org/2010/12/write-your-passwords-down.html
# via http://news.ycombinator.com/item?id=2016608
alpha = ("A".."Z").to_a
chars = alpha + 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(){}[]-+=.,;:~'.chars.to_a
class Array
def rand_el
self[rand(size)]
end
end
puts ([" "] + alpha).join(" ")
puts " " + "--" * alpha.size
alpha.each do |row|
puts row + "| " + (alpha.collect { |col| chars.rand_el }.join " ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment