realrand 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/random/online.rb +2 -2
- metadata +45 -48
- data/INSTALL +0 -12
- data/LICENSE +0 -5
- data/README +0 -110
- data/doc/readme.html +0 -143
- data/install.rb +0 -1022
- data/realrand-1.0.2.gem +0 -0
- data/realrand.gemspec +0 -34
- data/test/tc_all.rb +0 -9
- data/test/tc_entropy_pool.rb +0 -30
- data/test/tc_fourmilab.rb +0 -30
- data/test/tc_random_org.rb +0 -57
data/realrand-1.0.2.gem
DELETED
|
File without changes
|
data/realrand.gemspec
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'date'
|
|
2
|
-
Gem::Specification.new do |s|
|
|
3
|
-
s.name = %q{realrand}
|
|
4
|
-
s.version = "1.0.2"
|
|
5
|
-
s.date = Date.today.to_s
|
|
6
|
-
s.summary = %q{Generate real random numbers with Ruby.}
|
|
7
|
-
s.description =<<DESCRIPTION
|
|
8
|
-
A lot of algorithms in cryptography etc. depend on good random numbers,
|
|
9
|
-
i.e. random numbers that are "real" random and not just generated by
|
|
10
|
-
a so called pseudo-random generator.
|
|
11
|
-
|
|
12
|
-
You cannot create real random numbers using a computer and an
|
|
13
|
-
algorithm. Only nature creates real randomness (just take a look around
|
|
14
|
-
the next time you are surrounded by a group of people.).
|
|
15
|
-
|
|
16
|
-
Real randomness occurs e.g. in atmospheric noise, during radioactive
|
|
17
|
-
decay, or in a lava lamp. Fortunately, you do not have to listen to an
|
|
18
|
-
old radio the whole day or, even worse, deposit some uranium in your
|
|
19
|
-
living room and observe it with a Geiger-M�ller tube. Other people do so
|
|
20
|
-
(in a slightly modified manner, of course) and they kindly make their
|
|
21
|
-
results public.
|
|
22
|
-
DESCRIPTION
|
|
23
|
-
s.author = %q{Maik Schmidt}
|
|
24
|
-
s.email = %q{contact@maik-schmidt.de}
|
|
25
|
-
s.homepage = %q{http://www.maik-schmidt.de/realrand.html}
|
|
26
|
-
s.files = Dir.glob('**/*')
|
|
27
|
-
s.require_paths = %w{. lib}
|
|
28
|
-
s.autorequire = %q{random/online}
|
|
29
|
-
s.has_rdoc = true
|
|
30
|
-
s.rdoc_options = ["--main", "README"]
|
|
31
|
-
s.extra_rdoc_files = ["README"]
|
|
32
|
-
s.test_files = %w{test/tc_all.rb}
|
|
33
|
-
s.required_ruby_version = Gem::Version::Requirement.new(">= 1.8.0")
|
|
34
|
-
end
|
data/test/tc_all.rb
DELETED
data/test/tc_entropy_pool.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'test/unit'
|
|
4
|
-
require '../lib/random/online'
|
|
5
|
-
|
|
6
|
-
class TC_EntropyPool < Test::Unit::TestCase # :nodoc:
|
|
7
|
-
def setup
|
|
8
|
-
@generator = Random::EntropyPool.new
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def test_illegal_amount
|
|
12
|
-
[257, -1].each { |x|
|
|
13
|
-
assert_raises(RangeError) { @generator.randbyte(x) }
|
|
14
|
-
}
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_zero_amount
|
|
18
|
-
assert_equal([], @generator.randbyte(0))
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_randbyte
|
|
22
|
-
[1, 2, 10, 256].each { |x|
|
|
23
|
-
numbers = @generator.randbyte(x, false)
|
|
24
|
-
assert_equal(x, numbers.length)
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# vim:sw=2
|
|
30
|
-
|
data/test/tc_fourmilab.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'test/unit'
|
|
4
|
-
require '../lib/random/online'
|
|
5
|
-
|
|
6
|
-
class TC_FourmiLab < Test::Unit::TestCase # :nodoc:
|
|
7
|
-
def setup
|
|
8
|
-
@generator = Random::FourmiLab.new
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def test_illegal_amount
|
|
12
|
-
[2049, -1].each { |x|
|
|
13
|
-
assert_raises(RangeError) { @generator.randbyte(x) }
|
|
14
|
-
}
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_zero_amount
|
|
18
|
-
assert_equal([], @generator.randbyte(0))
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_randbyte
|
|
22
|
-
[1, 2, 10, 2048].each { |x|
|
|
23
|
-
numbers = @generator.randbyte(x)
|
|
24
|
-
assert_equal(x, numbers.length)
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# vim:sw=2
|
|
30
|
-
|
data/test/tc_random_org.rb
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'test/unit'
|
|
4
|
-
require '../lib/random/online'
|
|
5
|
-
|
|
6
|
-
class TC_RandomOrg < Test::Unit::TestCase # :nodoc:
|
|
7
|
-
def setup
|
|
8
|
-
@generator = Random::RandomOrg.new
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def test_illegal_amount
|
|
12
|
-
[10_001, -1].each { |x|
|
|
13
|
-
assert_raises(RangeError) { @generator.randnum(x, 1, 100) }
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
[16_385, -1].each { |x|
|
|
17
|
-
assert_raises(RangeError) { @generator.randbyte(x) }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
[
|
|
21
|
-
[1, -1_000_000_001, 100],
|
|
22
|
-
[1, 1, 1_000_000_001],
|
|
23
|
-
[1, 1, 0],
|
|
24
|
-
[1, 1, 1],
|
|
25
|
-
].each { |num, min, max|
|
|
26
|
-
assert_raises(RangeError) { @generator.randnum(num, min, max) }
|
|
27
|
-
}
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def test_zero_amount
|
|
31
|
-
assert_equal([], @generator.randnum(0, 1, 100))
|
|
32
|
-
assert_equal([], @generator.randbyte(0))
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def test_randnum
|
|
36
|
-
[
|
|
37
|
-
[1, -1_000_000_000, 1_000_000_000],
|
|
38
|
-
[1, 1, 2],
|
|
39
|
-
[5, 20, 100],
|
|
40
|
-
[1000, 1, 6],
|
|
41
|
-
].each { |num, min, max|
|
|
42
|
-
numbers = @generator.randnum(num, min, max)
|
|
43
|
-
assert_equal(num, numbers.length)
|
|
44
|
-
numbers.each { |x| assert(x >= min && x <= max) }
|
|
45
|
-
}
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_randbyte
|
|
49
|
-
[1, 2, 10, 100].each { |x|
|
|
50
|
-
numbers = @generator.randbyte(x)
|
|
51
|
-
assert_equal(x, numbers.length)
|
|
52
|
-
}
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# vim:sw=2
|
|
57
|
-
|