diff options
Diffstat (limited to 'lib/securerandom.rb')
-rw-r--r-- | lib/securerandom.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/securerandom.rb b/lib/securerandom.rb index e04251bb67..d238a35406 100644 --- a/lib/securerandom.rb +++ b/lib/securerandom.rb @@ -57,6 +57,14 @@ module SecureRandom n ||= 16 if defined? OpenSSL::Random + @pid = $$ if !defined?(@pid) + pid = $$ + if @pid != pid + now = Time.now + ary = [now.to_i, now.nsec, @pid, pid] + OpenSSL::Random.seed(ary.to_s) + @pid = pid + end return OpenSSL::Random.random_bytes(n) end |