Skip to content

Instantly share code, notes, and snippets.

@nisargshah100
Created December 4, 2012 18:02
Show Gist options
  • Save nisargshah100/4206936 to your computer and use it in GitHub Desktop.
Save nisargshah100/4206936 to your computer and use it in GitHub Desktop.
def generate_unique_token
options = { :length => 8, :chars => ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a }
Array.new(options[:length]) { options[:chars].to_a[rand(options[:chars].to_a.size)] }.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment