From 1dfebd4f0d25ecf50ba4e320234523d9ee3f7523 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sat, 4 Oct 2008 21:10:36 +0200 Subject: 1.8 compatibility for random_number method on SecureRandom. 1.9 has its own version. --- activesupport/lib/active_support/secure_random.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/secure_random.rb') 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 -- cgit v1.2.3