enigma_encrypto 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/bin/crack +5 -0
- data/bin/decrypt +5 -0
- data/bin/encrypt +5 -0
- data/encrypted.txt +1 -0
- data/enigma_encrypto.gemspec +22 -0
- data/lib/enigma_encrypto/crack.rb +80 -0
- data/lib/enigma_encrypto/cracker.rb +52 -0
- data/lib/enigma_encrypto/dateoffset_gen.rb +29 -0
- data/lib/enigma_encrypto/decrypt.rb +70 -0
- data/lib/enigma_encrypto/encrypt.rb +68 -0
- data/lib/enigma_encrypto/encrypted.txt +1 -0
- data/lib/enigma_encrypto/file_handler.rb +49 -0
- data/lib/enigma_encrypto/key_gen.rb +36 -0
- data/lib/enigma_encrypto/lib_helper.rb +6 -0
- data/lib/enigma_encrypto/rotation_num_gen.rb +40 -0
- data/lib/enigma_encrypto/rotator.rb +24 -0
- data/lib/enigma_encrypto/serialize.rb +70 -0
- data/lib/enigma_encrypto/testfile.txt +1 -0
- data/lib/enigma_encrypto/testfile2.txt +1 -0
- data/lib/enigma_encrypto/version.rb +3 -0
- data/lib/enigma_encrypto.rb +19 -0
- data/spec/coverage/.last_run.json +5 -0
- data/spec/coverage/.resultset.json +7 -0
- data/spec/coverage/.resultset.json.lock +0 -0
- data/spec/crack_spec.rb +74 -0
- data/spec/cracker_spec.rb +49 -0
- data/spec/dateoffset_gen_spec.rb +40 -0
- data/spec/decrypt_spec.rb +63 -0
- data/spec/decrypted.txt +0 -0
- data/spec/empty.txt +0 -0
- data/spec/encrypt_spec.rb +70 -0
- data/spec/encrypted.txt +1 -0
- data/spec/file_handler_spec.rb +60 -0
- data/spec/key_gen_spec.rb +53 -0
- data/spec/rotation_num_gen_spec.rb +55 -0
- data/spec/rotator_spec.rb +63 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/testfile.txt +1 -0
- data/spec/testfile2.txt +0 -0
- metadata +138 -0
@@ -0,0 +1 @@
|
|
1
|
+
abcdefghijklmnopqrstuvwxyz..end..
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "enigma_encrypto/version"
|
2
|
+
require "enigma_encrypto/crack"
|
3
|
+
require "enigma_encrypto/encrypt"
|
4
|
+
require "enigma_encrypto/decrypt"
|
5
|
+
|
6
|
+
module EnigmaEncrypto
|
7
|
+
def self.encrypt
|
8
|
+
encrypto = EnigmaEncrypto::Encrypt.new
|
9
|
+
encrypto.action
|
10
|
+
end
|
11
|
+
def self.decrypt
|
12
|
+
decrypto = EnigmaEncrypto::Decrypt.new
|
13
|
+
decrypto.action
|
14
|
+
end
|
15
|
+
def self.crack
|
16
|
+
cracko = EnigmaEncrypto::Crack.new
|
17
|
+
cracko.action
|
18
|
+
end
|
19
|
+
end
|
File without changes
|
data/spec/crack_spec.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe Crack do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@crack = Crack.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Crack object @crack" do
|
10
|
+
|
11
|
+
it "should be a crack object" do
|
12
|
+
expect(@crack.class).to be Crack
|
13
|
+
end
|
14
|
+
it "should have an instance of Rotator obj" do
|
15
|
+
expect(@crack.instance_variable_get(:@rotator).class) == Rotator
|
16
|
+
end
|
17
|
+
it "should have an instance of FileHandler obj" do
|
18
|
+
expect(@crack.instance_variable_get(:@file_handler).class) == FileHandler
|
19
|
+
end
|
20
|
+
it "should have an instance of RotationNumGen obj" do
|
21
|
+
expect(@crack.instance_variable_get(:@rotation_num_gen).class) == RotationNumGen
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "methods" do
|
27
|
+
|
28
|
+
before :each do
|
29
|
+
@crack.instance_variable_set(:@encrypted, "encrypted.txt")
|
30
|
+
@crack.instance_variable_set(:@cracked, "cracked.txt")
|
31
|
+
@crack.instance_variable_set(:@date, "300915")
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#get_command_args" do
|
35
|
+
|
36
|
+
it "should be false for incorrect number of argument" do
|
37
|
+
expect(@crack.get_command_args).to eql false
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#check_command_args" do
|
43
|
+
|
44
|
+
it "should return true for valid files" do
|
45
|
+
expect(@crack.check_command_args) == true
|
46
|
+
end
|
47
|
+
it "should be false for invalid files" do
|
48
|
+
@crack.instance_variable_set(:@encrypted, "empty.txt")
|
49
|
+
expect(@crack.check_command_args) == false
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#get_crack_key" do
|
55
|
+
it "should return an array of size four" do
|
56
|
+
expect(@crack.get_crack_key.class).to eql Array
|
57
|
+
end
|
58
|
+
it "should contain for elements" do
|
59
|
+
expect(@crack.get_crack_key.size).to eq 4
|
60
|
+
end
|
61
|
+
it "should give accurate result" do
|
62
|
+
expect(@crack.get_crack_key).to eq [-15, 14, -18, -36]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#action" do
|
67
|
+
it "#should exit if error occurs" do
|
68
|
+
expect { @crack.action }.to raise_error(SystemExit)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe "Cracker" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
opened_file = File.open("encrypted.txt", "r")
|
7
|
+
length = opened_file.size
|
8
|
+
@cracker = Cracker.new(opened_file, length, 7225)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "Cracker object" do
|
12
|
+
it "should be an instance of Cracker class" do
|
13
|
+
expect(@cracker).to be_an_instance_of Cracker
|
14
|
+
end
|
15
|
+
it "should have a character_map" do
|
16
|
+
expect(@cracker.instance_variable_get(:@character_map).nil?).to be false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#locate_position_to_start_crack" do
|
21
|
+
it "should return a number less than 7" do
|
22
|
+
expect(@cracker.locate_position_to_start_crack).to be 3
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#needed_four_of_file" do
|
27
|
+
it "should return an array of four elements" do
|
28
|
+
expect(@cracker.needed_four_of_file.size).to be 4
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#the_end_arr" do
|
33
|
+
it "should index for character in character_map" do
|
34
|
+
expect(@cracker.the_end_arr).to eq [37,37,4,13,3,37,37]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#creating_key" do
|
39
|
+
it "should create an array of keys" do
|
40
|
+
expect(@cracker.creating_key).to eq [-9, 16, -16, -32]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#get_key" do
|
45
|
+
it "get_key by calling all methods" do
|
46
|
+
expect(@cracker.get_key).to eq [-9, 16, -16, -32]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe "DateOffsetGen obj" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@offsetgen = DateOffsetGen.new
|
7
|
+
@today = @offsetgen.todays_date
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "@offsetgen" do
|
11
|
+
|
12
|
+
it "should exist as an obj of OffsetGen" do
|
13
|
+
expect(@offsetgen.class).to eql DateOffsetGen
|
14
|
+
end
|
15
|
+
it "should have a non empty today variable" do
|
16
|
+
expect(@offsetgen.instance_variable_get(:@todays_date).class) == Time
|
17
|
+
expect(@today.nil?).to eql false
|
18
|
+
expect(@today.to_s.length).to eql 6
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#get_offset" do
|
24
|
+
|
25
|
+
it "should return last 4 digits of todays square" do
|
26
|
+
@offsetgen.todays_date = 301619
|
27
|
+
expect(@offsetgen.get_offset) == [1, 1, 6, 1]
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#get_decrypter_offset" do
|
33
|
+
|
34
|
+
it "should return last 4 digits of given date square" do
|
35
|
+
expect(@offsetgen.get_decrypter_offset(301619)) == [1, 1, 6, 1]
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe Decrypt do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@decrypter = Decrypt.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "@decrypter" do
|
10
|
+
|
11
|
+
it "should be an Decrypt obj" do
|
12
|
+
expect(@decrypter.class).to be Decrypt
|
13
|
+
end
|
14
|
+
it "should have an instance of Rotator obj" do
|
15
|
+
expect(@decrypter.instance_variable_get(:@rotator).class) == Rotator
|
16
|
+
end
|
17
|
+
it "should have an instance of FileHandler obj" do
|
18
|
+
expect(@decrypter.instance_variable_get(:@file_handler).class) == FileHandler
|
19
|
+
end
|
20
|
+
it "should have an instance of RotationNumGen obj" do
|
21
|
+
expect(@decrypter.instance_variable_get(:@rotation_num_gen).class) == RotationNumGen
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#methods" do
|
27
|
+
|
28
|
+
before :all do
|
29
|
+
@decrypter.instance_variable_set(:@encrypted, "encrypted.txt")
|
30
|
+
@decrypter.instance_variable_set(:@decrypted, "decrypted.txt")
|
31
|
+
@decrypter.instance_variable_set(:@key, "12345")
|
32
|
+
@decrypter.instance_variable_set(:@date, "300915")
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#get_command_args" do
|
36
|
+
|
37
|
+
it "should be false for incorrect number of argument" do
|
38
|
+
expect(@decrypter.get_command_args).to eql false
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#check_command_args" do
|
44
|
+
|
45
|
+
it "should return true for valid files" do
|
46
|
+
expect(@decrypter.check_command_args) == true
|
47
|
+
end
|
48
|
+
it "should be false for invalid files" do
|
49
|
+
@decrypter.instance_variable_set(:@encrypted, "t.txt")
|
50
|
+
expect(@decrypter.check_command_args) == false
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#action" do
|
56
|
+
it "#should exit if error occurs" do
|
57
|
+
expect { @decrypter.action }.to raise_error(SystemExit)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/decrypted.txt
ADDED
File without changes
|
data/spec/empty.txt
ADDED
File without changes
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe Encrypt do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@encrypter = Encrypt.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "@encrypter" do
|
10
|
+
|
11
|
+
it "should be an Encrypt obj" do
|
12
|
+
expect(@encrypter.class).to be Encrypt
|
13
|
+
end
|
14
|
+
it "should have an instance of Rotator obj" do
|
15
|
+
expect(@encrypter.instance_variable_get(:@rotator).class) == Rotator
|
16
|
+
end
|
17
|
+
it "should have an instance of FileHandler obj" do
|
18
|
+
expect(@encrypter.instance_variable_get(:@file_handler).class) == FileHandler
|
19
|
+
end
|
20
|
+
it "should have an instance of RotationNumGen obj" do
|
21
|
+
expect(@encrypter.instance_variable_get(:@rotation_num_gen).class) == RotationNumGen
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#get_command_args" do
|
27
|
+
|
28
|
+
it "should be false for incorrect number of argument" do
|
29
|
+
expect(@encrypter.get_command_args).to eql false
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#check_command_args" do
|
35
|
+
|
36
|
+
before :all do
|
37
|
+
@encrypter.instance_variable_set(:@message, "testfile.txt")
|
38
|
+
@encrypter.instance_variable_set(:@encrypted, "encrypted.txt")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return true for valid files" do
|
42
|
+
expect(@encrypter.check_command_args) == true
|
43
|
+
end
|
44
|
+
it "should be false for invalid files" do
|
45
|
+
@encrypter.instance_variable_set(:@message, "t.txt")
|
46
|
+
expect(@encrypter.check_command_args) == false
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#encrypt" do
|
52
|
+
|
53
|
+
it "should create a non-empty encrypted file" do
|
54
|
+
@encrypter.stub(:encrypt).and_return(File.open("encrypted.txt", "w") { |file| file.write("sedrftvg") })
|
55
|
+
@encrypter.encrypt
|
56
|
+
expect(File.file? ("encrypted.txt")).to eq true
|
57
|
+
expect(File.zero? ("encrypted.txt")).to eq false
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#action" do
|
63
|
+
|
64
|
+
it "#should exit if error occurs" do
|
65
|
+
expect { @encrypter.action }.to raise_error(SystemExit)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/spec/encrypted.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.zopc3stg7wxk.01oc45sg89wkkkc.pk9
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe FileHandler do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@filehandler = FileHandler.new
|
7
|
+
@file1, @file2 = "testfile.txt", "encrypt.txt"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "@filehandler" do
|
11
|
+
|
12
|
+
it "should be a FileHandler obj" do
|
13
|
+
expect(@filehandler.class).to be FileHandler
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#check_file_useability" do
|
19
|
+
|
20
|
+
it "should return true when the two files are good to go" do
|
21
|
+
expect(@filehandler.check_file_useability(@file1, @file2)) == true
|
22
|
+
end
|
23
|
+
it "should return false if file1 is not eligible for operation" do
|
24
|
+
#testfile2.txt is an empty file.
|
25
|
+
@file1 = "testfile2.txt"
|
26
|
+
expect(@filehandler.check_file_useability(@file1, @file2)) == false
|
27
|
+
#unexistent.txt is an unexistent file.
|
28
|
+
@file1 = "unexistent.txt"
|
29
|
+
expect(@filehandler.check_file_useability(@file1, @file2)) == false
|
30
|
+
end
|
31
|
+
it "should return an operation if file2 exists." do
|
32
|
+
#file to be written to already exists.
|
33
|
+
@filehandler.stub(:operation).and_return("cancel")
|
34
|
+
@file2 = "testfile2.txt"
|
35
|
+
expect(@filehandler.check_file_useability(@file1, @file2)) == :operation
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# describe "#read" do
|
41
|
+
|
42
|
+
# it "should open a file for reading" do
|
43
|
+
# readable = @filehandler.read(@file1)
|
44
|
+
# expect(readable.closed?) == false
|
45
|
+
# end
|
46
|
+
|
47
|
+
# end
|
48
|
+
|
49
|
+
# describe "#writer" do
|
50
|
+
|
51
|
+
# it "should write to file" do
|
52
|
+
# initial = File.new("testfile2.txt").size
|
53
|
+
# writable = @filehandler.writer("testfile2.txt", "tgyhj")
|
54
|
+
# final = File.new("testfile2.txt").size
|
55
|
+
# expect(final > initial ) == true
|
56
|
+
# end
|
57
|
+
|
58
|
+
# end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe KeyGen do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@keygen = KeyGen.new
|
7
|
+
@rand_num = @keygen.rand_num
|
8
|
+
@keys = @keygen.initial_rotation_keys
|
9
|
+
@decryption_key = @keygen.initial_decryption_keys("12345")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "@keygen" do
|
13
|
+
|
14
|
+
it "should exist as an obj of KeyGen" do
|
15
|
+
expect(@keygen.class).to eql KeyGen
|
16
|
+
end
|
17
|
+
it "should have an instance variables" do
|
18
|
+
expect(@keygen.instance_variable_get(:@rand_num).class) == Random
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#initial_rotation_keys" do
|
24
|
+
|
25
|
+
it "should return an array of four numbers." do
|
26
|
+
expect(@keys.class).to equal(Array)
|
27
|
+
expect(@keys.nil?).to eql false
|
28
|
+
@keygen.rand_num = "12345"
|
29
|
+
expect(@keygen.initial_rotation_keys).to eq [12, 23, 34, 45]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#display_key" do
|
35
|
+
|
36
|
+
it "should show key for encryption" do
|
37
|
+
@keygen.rand_num = ["1", "2", "3", "4", "5"]
|
38
|
+
expect(@keygen.display_key).to eql "12345"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#initial_decryption_keys" do
|
44
|
+
|
45
|
+
it "should return an array of four numbers." do
|
46
|
+
expect(@decryption_key.class).to equal(Array)
|
47
|
+
expect(@decryption_key.nil?).to eql false
|
48
|
+
expect(@decryption_key) == ([12, 23, 34, 45])
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe RotationNumGen do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@rotation_num_gen = RotationNumGen.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "RotationNumGen obj" do
|
10
|
+
|
11
|
+
it "should be an instance of RotationNumGen" do
|
12
|
+
expect(@rotation_num_gen.class).to be RotationNumGen
|
13
|
+
end
|
14
|
+
it "should have an Array of key values" do
|
15
|
+
expect(@rotation_num_gen.instance_variable_get(:@key).class) == KeyGen
|
16
|
+
expect(@rotation_num_gen.key.nil?).to be false
|
17
|
+
expect(@rotation_num_gen.key.is_a? Array) == true
|
18
|
+
end
|
19
|
+
it "should have an Array of offset values" do
|
20
|
+
expect(@rotation_num_gen.instance_variable_get(:@today_date).class) == DateOffsetGen
|
21
|
+
expect(@rotation_num_gen.offset.nil?).to be false
|
22
|
+
expect(@rotation_num_gen.offset.is_a? Array) == true
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#rotation_num_array" do
|
28
|
+
|
29
|
+
it "should return correct rotation number" do
|
30
|
+
@rotation_num_gen.offset = [2,3,4,5]
|
31
|
+
@rotation_num_gen.key = [12,24,45,56]
|
32
|
+
expect(@rotation_num_gen.rotation_num_array).to eq [14,27,49,61]
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#reverse_num_array" do
|
38
|
+
|
39
|
+
it "should get rotation number for decryption" do
|
40
|
+
array = @rotation_num_gen.reverse_num_array("12345", "201514")
|
41
|
+
expect(array).to eq [14,24,43,51]
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#crack_num_arr" do
|
47
|
+
|
48
|
+
it "should get rotation number for decryption" do
|
49
|
+
array = @rotation_num_gen.crack_num_arr([2,3,4,5], [12,24,45,56])
|
50
|
+
expect(array).to eq [14,27,49,61]
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe Rotator do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@rotator = Rotator.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Rotator obj" do
|
10
|
+
it "should be an object of Rotator class" do
|
11
|
+
expect(@rotator).to be_an_instance_of Rotator
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#character_map_creation" do
|
16
|
+
|
17
|
+
it "should create array" do
|
18
|
+
expect(@rotator.character_map_creation.class).to be Array
|
19
|
+
end
|
20
|
+
it "should create array that contains lowercase letters" do
|
21
|
+
expect(@rotator.character_map_creation.include? "g" && "f").to eq true
|
22
|
+
end
|
23
|
+
it "should create array that contains numbers" do
|
24
|
+
expect(@rotator.character_map_creation.include? "4" && "7").to eq true
|
25
|
+
end
|
26
|
+
it "should create array that contains period, comma and space" do
|
27
|
+
expect(@rotator.character_map_creation.include? "," && "." && " ").to eq true
|
28
|
+
end
|
29
|
+
it "should not contain Upcase letter" do
|
30
|
+
expect(@rotator.character_map_creation.include? "G" && "F").to eq false
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#rotator" do
|
36
|
+
|
37
|
+
it "should return a hash of character_map and rotated character_map" do
|
38
|
+
expect(@rotator.rotator(5).is_a?Hash).to eq true
|
39
|
+
rotated_characters = @rotator.rotator(5)
|
40
|
+
expect(rotated_characters["a"]).to eql "f"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#rotate_text" do
|
46
|
+
|
47
|
+
it "should return a rotated string text" do
|
48
|
+
rotate_text = @rotator.rotate_text("r", 1)
|
49
|
+
expect(rotate_text.class).to eq String
|
50
|
+
expect(rotate_text).to eql "s"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
describe "#reverse_text" do
|
55
|
+
|
56
|
+
it "should rotate backwards" do
|
57
|
+
reverse_text = @rotator.reverse_text("r", 1)
|
58
|
+
expect(reverse_text.class).to eq String
|
59
|
+
expect(reverse_text).to eql "q"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "coveralls"
|
2
|
+
Coveralls.wear!
|
3
|
+
require_relative "../lib/crack"
|
4
|
+
require_relative "../lib/dateoffset_gen"
|
5
|
+
require_relative "../lib/decrypt"
|
6
|
+
require_relative "../lib/encrypt"
|
7
|
+
require_relative "../lib/file_handler"
|
8
|
+
require_relative "../lib/key_gen"
|
9
|
+
require_relative "../lib/rotator"
|
10
|
+
require_relative "../lib/rotation_num_gen"
|
11
|
+
require_relative "../lib/cracker.rb"
|
data/spec/testfile.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ABCDEFGHIJKLMNOPQRSTUV
|
data/spec/testfile2.txt
ADDED
File without changes
|