diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-10-04 21:10:36 +0200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-10-04 21:11:30 +0200 |
commit | 1dfebd4f0d25ecf50ba4e320234523d9ee3f7523 (patch) | |
tree | 56edc41aa201b47804cb1eebd34f2636e79bbd8f /activesupport/lib | |
parent | 923eb9569c2289581d6a48dbd4447202a5ac93d8 (diff) | |
download | rails-1dfebd4f0d25ecf50ba4e320234523d9ee3f7523.tar.gz rails-1dfebd4f0d25ecf50ba4e320234523d9ee3f7523.tar.bz2 rails-1dfebd4f0d25ecf50ba4e320234523d9ee3f7523.zip |
1.8 compatibility for random_number method on SecureRandom.
1.9 has its own version.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/secure_random.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/secure_random.rb b/activesupport/lib/active_support/secure_random.rb index 688165f9a3..97971e8830 100644 --- a/activesupport/lib/active_support/secure_random.rb +++ b/activesupport/lib/active_support/secure_random.rb @@ -164,13 +164,13 @@ module ActiveSupport hex = n.to_s(16) hex = '0' + hex if (hex.length & 1) == 1 bin = [hex].pack("H*") - mask = bin[0].ord + mask = bin[0] mask |= mask >> 1 mask |= mask >> 2 mask |= mask >> 4 begin rnd = SecureRandom.random_bytes(bin.length) - rnd[0] = (rnd[0].ord & mask).chr + rnd[0] = rnd[0] & mask end until rnd < bin rnd.unpack("H*")[0].hex else |