crypt-isaac 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +62 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/crypt-isaac.gemspec +27 -33
- data/lib/crypt/isaac.rb +213 -0
- data/lib/crypt/isaac/version.rb +5 -0
- metadata +84 -52
- data/LICENSE +0 -26
- data/README +0 -78
- data/TODO +0 -3
- data/VERSIONS +0 -3
- data/lib/crypt-isaac.rb +0 -171
- data/setup.rb +0 -596
- data/test/TC_ISAAC.rb +0 -76
data/test/TC_ISAAC.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
if ARGV[0] == 'local'
|
3
|
-
begin
|
4
|
-
require '../lib/crypt-isaac.rb'
|
5
|
-
rescue Exception
|
6
|
-
require './lib/crypt-isaac.rb'
|
7
|
-
end
|
8
|
-
else
|
9
|
-
begin
|
10
|
-
require 'crypt-isaac'
|
11
|
-
rescue Exception
|
12
|
-
require './lib/crypt-isaac.rb'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class TC_ISAAC < Test::Unit::TestCase
|
17
|
-
def setup
|
18
|
-
assert_nothing_raised("Failed to create a Crypt::ISAAC object.") do
|
19
|
-
@generator = Crypt::ISAAC.new
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def testKind
|
24
|
-
assert_kind_of(Crypt::ISAAC,@generator,"The created object is not a Crypt::ISAAC or subclass thereof.")
|
25
|
-
end
|
26
|
-
|
27
|
-
def testInteger
|
28
|
-
assert_nothing_raised("Failed while generating an integer random number.") do
|
29
|
-
mynum = @generator.rand(1000000)
|
30
|
-
assert_kind_of(Integer,mynum,"The generator failed to return an integer number in response to @generator.rand(1000000).")
|
31
|
-
assert((mynum >= 0),"The generator returned a number that is less than 0 (#{mynum}).")
|
32
|
-
assert((mynum < 1000000),"The generator returned a number that is greater than or equal to 1000000 (#{mynum}).")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def testFloat
|
37
|
-
assert_nothing_raised("Failed while generating a floating point random number.") do
|
38
|
-
mynum = @generator.rand()
|
39
|
-
assert_kind_of(Float,mynum,"The generator failed to return a floating point number in response to @generator.rand().")
|
40
|
-
assert((mynum >= 0),"The generator returned a number that is less than 0 (#{mynum}).")
|
41
|
-
assert((mynum < 1),"The generator returned a number that is greater than or equal to 1 (#{mynum}).")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def testIterations
|
46
|
-
puts
|
47
|
-
count = 0
|
48
|
-
assert_nothing_raised("Failed on iteration #{count} while trying to generate 100000 random numbers.") do
|
49
|
-
100000.times do
|
50
|
-
count += 1
|
51
|
-
x = @generator.rand(4294967295)
|
52
|
-
print [x].pack('V').unpack('H8') if count % 1000 == 0
|
53
|
-
if (count % 7000) == 0
|
54
|
-
print "\n"
|
55
|
-
else
|
56
|
-
print " " if count % 1000 == 0
|
57
|
-
end
|
58
|
-
end
|
59
|
-
puts "\n100000 numbers generated"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def testDualStreams
|
64
|
-
g1 = nil
|
65
|
-
g2 = nil
|
66
|
-
assert_nothing_raised("Failed to pull numbers from two independent streams.") do
|
67
|
-
g1 = Crypt::ISAAC.new
|
68
|
-
g2 = Crypt::ISAAC.new
|
69
|
-
assert((g1 != g2),"The generators are the same. This should not happen.")
|
70
|
-
1000.times do
|
71
|
-
g1.rand(4294967295)
|
72
|
-
g2.rand(4294967295)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|