Skip to content

Instantly share code, notes, and snippets.

@ohlol
Created August 26, 2009 05:47
Show Gist options
  • Save ohlol/175344 to your computer and use it in GitHub Desktop.
Save ohlol/175344 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Generate a random string and print it. Accepts an optional string length.
require 'base64'
string = ''
len = ARGV[0] ? ARGV[0].to_i : 8
len.times { string += (rand(74) + 48).chr }
puts [string].pack('m')[1,len]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment