Tuesday, July 26, 2011

How to generate a random string in ruby

Just ran into this while googling for random string generation in ruby. This is pretty awesome:

Also, thanks to divisionoftigers for posting it on stackoverflow here

Let me put it directly here instead:
require 'active_support/secure_random'
random_string
= ActiveSupport::SecureRandom.hex(16)

No comments:

Post a Comment