Reputation: 4113
I am looking for advise about best practices of generating unique hash strings in Ruby/Rails. Usually I use MD5, SHA etc to do this, but it was not quite straightforward to choose source values for hash (timestamps not always prefered to be used).
So my question are:
Any advise would be appreciated.
Upvotes: 9
Views: 4784
Reputation: 138002
Use UUIDs:
In ruby 1.9
require 'securerandom'
SecureRandom.uuid
In ruby 1.8
$ gem install uuidtools
UUIDTools::UUID.random_create
Upvotes: 19