Create a gist now

Instantly share code, notes, and snippets.

Generating a random password in one line
# Ruby 1.9.2
password="".tap{|s| 8.times { s << sprintf("%c", } }
# Another way
# Using only safe/printable characters
valid_chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
password = valid_chars.shuffle.take(8).join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment