super_random 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +2 -2
- data/lib/super_random/super_random.rb +16 -11
- data/lib/super_random/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b911b7150cf576f96ffcfd6180dc7bffc25e1e3
|
4
|
+
data.tar.gz: 53a850f144d7908d762f3cf1dc1a77a7cae203ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7a29619d1473b51fe1d7d4a47c80facbe622b13f8df19da7ea458ef27a01e8a026adcf5d69d63fd7376a5d29118aa1d660e8cb98788e96ef522f2e95f77d2d3
|
7
|
+
data.tar.gz: aa56f4060ffa1366fcf20ce96a38adabebda122bf0d036e61207d76494a1277991fedfe604f87f6a400d1ccb1e786b47fc990fa67c984dec0d0c922da969b286
|
data/README.rdoc
CHANGED
@@ -23,10 +23,10 @@ SuperRandom combines RealRand's three online real random services to create a mo
|
|
23
23
|
super_random.rand #=> 0.16882225652425537
|
24
24
|
super_random.rand(100) #=> 85
|
25
25
|
|
26
|
-
# The "
|
26
|
+
# The "services" attribute gives the number of online services used.
|
27
27
|
# It's possible for a service to fail.
|
28
28
|
# Ultimately, SuperRandom uses SecureRandom as a failsafe.
|
29
|
-
super_random.
|
29
|
+
super_random.services #=> 3
|
30
30
|
|
31
31
|
== INSTALL:
|
32
32
|
|
@@ -1,22 +1,26 @@
|
|
1
1
|
class SuperRandom
|
2
2
|
|
3
|
-
def self.randbyte(r,
|
4
|
-
return r.randbyte
|
3
|
+
def self.randbyte(r,s)
|
4
|
+
return r.randbyte
|
5
5
|
rescue Exception
|
6
6
|
warn "RealRand's #{s} failed."
|
7
7
|
return nil
|
8
8
|
end
|
9
9
|
|
10
|
-
attr_accessor :first_timeout, :second_timeout, :
|
10
|
+
attr_accessor :first_timeout, :second_timeout, :nevermind
|
11
|
+
attr_reader :randomness, :services
|
12
|
+
|
11
13
|
def initialize
|
12
14
|
@first_timeout = 3
|
13
15
|
@second_timeout = 6
|
14
16
|
@nevermind = true
|
15
|
-
@randomness = 0
|
17
|
+
@randomness = 0.0
|
18
|
+
@services = 0
|
16
19
|
end
|
17
20
|
|
18
21
|
def bytes(n=32)
|
19
|
-
@randomness = 0
|
22
|
+
@randomness = 0.0
|
23
|
+
@services = 0
|
20
24
|
|
21
25
|
r1 = RealRand::RandomOrg.new
|
22
26
|
r2 = RealRand::EntropyPool.new
|
@@ -24,9 +28,9 @@ class SuperRandom
|
|
24
28
|
|
25
29
|
a1 = a2 = a3 = nil
|
26
30
|
|
27
|
-
t1 = Thread.new{ a1 = SuperRandom.randbyte(r1,
|
28
|
-
t2 = Thread.new{ a2 = SuperRandom.randbyte(r2,
|
29
|
-
t3 = Thread.new{ a3 = SuperRandom.randbyte(r3,
|
31
|
+
t1 = Thread.new{ a1 = SuperRandom.randbyte(r1,'RandomOrg')[0...n] }
|
32
|
+
t2 = Thread.new{ a2 = SuperRandom.randbyte(r2,'EntropyPool')[0...n] }
|
33
|
+
t3 = Thread.new{ a3 = SuperRandom.randbyte(r3,'FourmiLab')[0...n] }
|
30
34
|
|
31
35
|
begin
|
32
36
|
Timeout.timeout(@first_timeout) do
|
@@ -49,11 +53,12 @@ class SuperRandom
|
|
49
53
|
end
|
50
54
|
|
51
55
|
a = n.times.inject([]){|b,i|b.push(SecureRandom.random_number(256))}
|
52
|
-
|
53
56
|
[a1, a2, a3].each do |b|
|
54
57
|
if b
|
55
|
-
|
56
|
-
n.
|
58
|
+
bl = b.length
|
59
|
+
@randomness += bl.to_f/n.to_f
|
60
|
+
@services += 1
|
61
|
+
n.times{|i|a[i]=(a[i]+b[i%bl])%256}
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
data/lib/super_random/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_random
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- carlosjhr64
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: realrand
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '2.0'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.0.
|
22
|
+
version: 2.0.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '2.0'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.0.
|
32
|
+
version: 2.0.2
|
33
33
|
description: |
|
34
34
|
You can't get more random than random, but you can try really, really, really hard.
|
35
35
|
|
@@ -65,9 +65,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '0'
|
67
67
|
requirements:
|
68
|
-
- 'ruby: ruby 2.
|
68
|
+
- 'ruby: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]'
|
69
69
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.5.2
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: You can't get more random than random, but you can try really, really, really
|