Skip to content

Instantly share code, notes, and snippets.

@saihoooooooo
Last active December 21, 2015 12:58
Show Gist options
  • Select an option

  • Save saihoooooooo/6309057 to your computer and use it in GitHub Desktop.

Select an option

Save saihoooooooo/6309057 to your computer and use it in GitHub Desktop.
Make random hash string.
#!/usr/bin/env ruby
if ARGV.empty?
puts 'plz input length.'
exit
end
len = ARGV[0].to_i
# candidates = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a
candidates = [*0..9, *'a'..'z', *'A'..'Z']
strArr = []
len.times {
strArr << candidates.sample
}
puts strArr.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment