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.
Use UUIDs:
In ruby 1.9
require 'securerandom'
SecureRandom.uuid
In ruby 1.8
$ gem install uuidtools
UUIDTools::UUID.random_create
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With