uuidtools 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/compat/securerandom.rb +5 -2
- data/lib/uuidtools/version.rb +1 -1
- data/spec/uuidtools/utility_spec.rb +5 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/compat/securerandom.rb
CHANGED
@@ -160,13 +160,16 @@ if !defined?(SecureRandom)
|
|
160
160
|
hex = n.to_s(16)
|
161
161
|
hex = '0' + hex if (hex.length & 1) == 1
|
162
162
|
bin = [hex].pack("H*")
|
163
|
-
|
163
|
+
first = bin[0..0]
|
164
|
+
mask = first.respond_to?(:ord) ? first.ord : first.sum(8)
|
164
165
|
mask |= mask >> 1
|
165
166
|
mask |= mask >> 2
|
166
167
|
mask |= mask >> 4
|
167
168
|
begin
|
168
169
|
rnd = SecureRandom.random_bytes(bin.length)
|
169
|
-
|
170
|
+
first = rnd[0..0]
|
171
|
+
ordinal = first.respond_to?(:ord) ? first.ord : first.sum(8)
|
172
|
+
rnd[0..0] = (ordinal & mask).chr
|
170
173
|
end until rnd < bin
|
171
174
|
rnd.unpack("H*")[0].hex
|
172
175
|
else
|
data/lib/uuidtools/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "../spec_helper.rb")
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe SecureRandom do
|
4
4
|
it "should correctly obtain random bits" do
|
5
5
|
bits = []
|
6
6
|
1000.times do
|
@@ -14,4 +14,8 @@ describe UUID, "when using utility methods" do
|
|
14
14
|
SecureRandom.random_bytes(16).size.should == 16
|
15
15
|
SecureRandom.random_bytes(6).size.should == 6
|
16
16
|
end
|
17
|
+
|
18
|
+
it "should return a sane random number" do
|
19
|
+
SecureRandom.random_number(5000).should < 5000
|
20
|
+
end
|
17
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuidtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Aman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-04 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|