I am creating a pastebin app and I want the pastes' IDs to be truly random. /dev/random
on Linux (hosted on a Linux machine) uses noise so it's output is truly random.
Currently I use this code to generate the IDs:
self.guid = Digest::SHA1.hexdigest(Time.new.to_s + (0...50).map{ ('a'..'z').to_a[rand(26)] }.join)
Does Ruby's rand
function use /dev/random
, and if not how can I use /dev/random
in Ruby? Thanks.