Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Generating a random password in one line

View random_password.rb
1 2 3 4 5 6 7
# Ruby 1.9.2
password="".tap{|s| 8.times { s << sprintf("%c",Random.new.rand(33..126)) } }
# Another way
password=(33..126).to_a.shuffle.take(8).map(&:chr).join
# 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
Something went wrong with that request. Please try again.