Skip to content

@fabrizioc1 /random_password.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Generating a random password in one line
# 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.