Skip to content

Instantly share code, notes, and snippets.

@mattweidner
Created March 30, 2016 04:53
Show Gist options
  • Save mattweidner/052465782be1342f1d6b984e877423d0 to your computer and use it in GitHub Desktop.
Save mattweidner/052465782be1342f1d6b984e877423d0 to your computer and use it in GitHub Desktop.

Revisions

  1. mattweidner created this gist Mar 30, 2016.
    9 changes: 9 additions & 0 deletions random_string.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/usr/bin/ruby

    # Source characters array
    range = [*'0'..'9',*'A'..'Z',*'a'..'z']
    puts "#{range}"

    # Build a 20 char random string from the source array.
    a = Array.new(20) { range.sample }.join
    puts "#{a}"