rotor_machine 1.0.13 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +2 -0
- data/.gitignore +1 -1
- data/README.md +7 -7
- data/certs/tammycravit.pem +25 -0
- data/lib/rotor_machine/factory.rb +20 -20
- data/lib/rotor_machine/version.rb +1 -1
- data/rotor_machine.gemspec +18 -15
- metadata +45 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 443abe9d94a7c609dc9e6e737a9cf134cc7c81d485977b7f32b9672572cacb4f
|
4
|
+
data.tar.gz: 4f9ac00ff8680eb8c1f10d385d6905a35d97d240da5b9ef209a3a26304f3e2d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1280cdc56b4e65ea14716c454316cd1c8b4411c92e944230ac67fe526f36f708108afb6a89c0b9f6662afa556e2c54c21035bf780ea0a2e75b45cd4a53e69726
|
7
|
+
data.tar.gz: f1225743be6ea1947a8d1fc1b0966f42f4686b38d7762cbfbd65baf27ccd0951bc7c64efdb5930d277f7b88f660eb3121cf7a29ddb32b1a506013c3673ccf88f
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -33,29 +33,29 @@ Or install it yourself as:
|
|
33
33
|
|
34
34
|
## Architecture
|
35
35
|
|
36
|
-
The [`RotorMachine::Machine`](http://www.rubydoc.info/
|
36
|
+
The [`RotorMachine::Machine`](http://www.rubydoc.info/github/tammycravit/rotor_machine/master/RotorMachine/Machine)
|
37
37
|
class serves as the entrypoint and orchestrator for an Enigma machine.
|
38
38
|
|
39
39
|
### Components of an Enigma machine
|
40
40
|
|
41
|
-
The Enigma machine, as represented by the [RotorMachine](http://www.rubydoc.info/
|
41
|
+
The Enigma machine, as represented by the [RotorMachine](http://www.rubydoc.info/github/tammycravit/rotor_machine/master)
|
42
42
|
module, consists of the following components:
|
43
43
|
|
44
|
-
* One or more [rotors](http://www.rubydoc.info/
|
44
|
+
* One or more [rotors](http://www.rubydoc.info/github/tammycravit/rotor_machine/master/RotorMachine/Rotor), which
|
45
45
|
perform the transposition ciphering and also rotate to produce a polyalphabetic (rather
|
46
46
|
than simple substitution) cipher.
|
47
47
|
|
48
|
-
* A [reflector](http://www.rubydoc.info/
|
48
|
+
* A [reflector](http://www.rubydoc.info/github/tammycravit/rotor_machine/master/RotorMachine/Reflector), which
|
49
49
|
performs a simple symmetric substitution of letters
|
50
50
|
|
51
|
-
* A [plugboard](http://www.rubydoc.info/
|
51
|
+
* A [plugboard](http://www.rubydoc.info/github/tammycravit/rotor_machine/master/RotorMachine/Plugboard), which
|
52
52
|
allows pairs of letters to be transposed on a per-message basis.
|
53
53
|
|
54
54
|
On an actual Enigma machine, these components are all electromechanical, and
|
55
55
|
the Enigma also included a keyboard, a grid of lights to show the results, and
|
56
56
|
in some cases a printer. Since this is a simulated Enigma, obviously, no
|
57
57
|
keyboard/printer are supplied here. In this simulation, the
|
58
|
-
[Machine](http://www.rubydoc.info/
|
58
|
+
[Machine](http://www.rubydoc.info/github/tammycravit/rotor_machine/master/RotorMachine/Machine)
|
59
59
|
class serves to encapsulate all of these components.
|
60
60
|
|
61
61
|
The polyalphabetic encryption of the Enigma comes from the fact that the
|
@@ -168,7 +168,7 @@ new_plaintext = machine.encipher(ciphertext) # => "THISI SASUP ERSEC RETME SSAG
|
|
168
168
|
|
169
169
|
The classes in
|
170
170
|
[`lib/rotor_machine/`](https://github.com/tammycravit/rotor_machine/tree/master/lib/rotor_machine)
|
171
|
-
all contain [documentation](http://www.rubydoc.info/
|
171
|
+
all contain [documentation](http://www.rubydoc.info/github/tammycravit/rotor_machine/master/) that
|
172
172
|
pretty exhaustively describe their operation.
|
173
173
|
The RSpec tests in the [`spec/`](https://github.com/tammycravit/rotor_machine/tree/master/spec)
|
174
174
|
directory are also instructive for how the library works and how to use it.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBh0YW1t
|
3
|
+
eWNyYXZpdC9EQz1tZS9EQz1jb20wHhcNMTgwMjE5MjMxNDQzWhcNMTkwMjE5MjMx
|
4
|
+
NDQzWjAjMSEwHwYDVQQDDBh0YW1teWNyYXZpdC9EQz1tZS9EQz1jb20wggGiMA0G
|
5
|
+
CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDDUddItdpGGMBoBfJZ2LWlXnfwEJWx
|
6
|
+
iOc478enSEQFOLXj3nVuTUhyac6MQFH6nB8CkNZt7MSokuWdQ7H//1Ajq+jeCwUm
|
7
|
+
WpjHF2BIL3WK7n8aAMH00p4gMAI4R8JnRjotmhUTIJCXtkIXoDTk1PGRzkH29q8+
|
8
|
+
dByUGmkAoX+iHqNRLbgiywLlpVapRT5B1nE+K8oETb0TilCfdvOh+91dM1LX/z69
|
9
|
+
uSOQOFoZSgnVNP/LTYaqDixdeEaDdslPRO1l8JSPdAzl1sn+YaeJwQbBWfbi+sGs
|
10
|
+
MB53CkLGDsz5MsrPx8b0iBNM/xFSEmXE+du3vCSAZktjNR7kNuFGbSOQW4SQkld6
|
11
|
+
mvw/Gi3TMmlgw2bELiXyUvEkHdkonFKMv9Rs2eq6Opw880YXl52/AcVi0dcsMZ3t
|
12
|
+
qp70xuUgsDF7zNdSfIgQzBX+GsmIIgbRQKUyGuXMnqUJlPm4fPnl5i3mIyZnqKyx
|
13
|
+
gg+2NNhKneabQF8wItZWdTGOVu87YFUOsosCAwEAAaN3MHUwCQYDVR0TBAIwADAL
|
14
|
+
BgNVHQ8EBAMCBLAwHQYDVR0OBBYEFMSFUfz/8w+SLDZIFy54jEKUPq4IMB0GA1Ud
|
15
|
+
EQQWMBSBEnRhbW15Y3Jhdml0QG1lLmNvbTAdBgNVHRIEFjAUgRJ0YW1teWNyYXZp
|
16
|
+
dEBtZS5jb20wDQYJKoZIhvcNAQELBQADggGBAC/hS37ZCB/MYxt6gE9i5qvjdY5j
|
17
|
+
qPiiQ7i5Yf2Gx6Jbe/wxiW1A3QcMdRvUSfIdC3XP3rYQf0AiyaQmbxhRn5e0LkYd
|
18
|
+
riChjHZxLQG3CKj+7YiUijIv0mgaw/lA0pEhMxIb/xY03Jwh64cg2FZrd/5wWLh2
|
19
|
+
QpyGVAktJp3rQolYO0fXbqRt40lg2+h2UWmaFvj++sFoCWdZzaopJZ3CS96IgUt+
|
20
|
+
sqm+r9HvzygOChJyLAjM8OwabZ4e2yRR2ZLiRxvHBL4FGf7hg6Y0YAvwvyRJw/7b
|
21
|
+
x6WTe0KO4pSZD02hl1A4gblx72eDvRwYkWO+dT1j9R+Wvrp/puwnzrLdThLwTsWQ
|
22
|
+
YGgdQBodP4Wqsew3nfbNJOKkqOnry4lWJugso3w2fe0nUbrWuaC3++J9Eazm++n/
|
23
|
+
F9wFDQvW5Nv6grw3Unc9miwN6NHA5kEjKzDDSXzWKSzAWbqzlMp/FxD+zP7NuibT
|
24
|
+
pjZmBE7TzW3JK1L4mE7lBh9bwUC5WoyMBDPT7A==
|
25
|
+
-----END CERTIFICATE-----
|
@@ -12,17 +12,17 @@ module RotorMachine
|
|
12
12
|
# The options hash for this method can accept the following named
|
13
13
|
# arguments:
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
15
|
+
# *:rotor_kind* - The type of rotor to create. Should be a symbol matching
|
16
|
+
# a rotor type constant in the {RotorMachine::Rotor} class,
|
17
|
+
# or a 26-character string giving the letter sequence for
|
18
|
+
# the rotor. Defaults to *:ROTOR_1* if not specified.
|
19
19
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
20
|
+
# *:initial_position* - The initial position of the rotor (0-based
|
21
|
+
# numeric position, or a letter on the rotor.) Defaults
|
22
|
+
# to 0 if not specified.
|
23
23
|
#
|
24
|
-
#
|
25
|
-
#
|
24
|
+
# *:step_size* - How many positions the rotor should advance with each
|
25
|
+
# step. Defaults to 1 if not specified.
|
26
26
|
#
|
27
27
|
# @param options [Hash] The options hash containing the options for the
|
28
28
|
# rotor.
|
@@ -69,17 +69,17 @@ module RotorMachine
|
|
69
69
|
# The options hash for this method can accept the following named
|
70
70
|
# arguments:
|
71
71
|
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
72
|
+
# *:reflector_kind* - The type of reflector to create. Should be a symbol matching
|
73
|
+
# a reflector type constant in the {RotorMachine::Reflector} class,
|
74
|
+
# or a 26-character string giving the letter sequence for
|
75
|
+
# the reflector. Defaults to *:REFLECTOR_A* if not specified.
|
76
76
|
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
77
|
+
# *:initial_position* - The initial position of the reflector (0-based
|
78
|
+
# numeric position, or a letter on the rotor.) Defaults
|
79
|
+
# to 0 if not specified.
|
80
80
|
#
|
81
81
|
# @param options [Hash] The options hash containing the options for the
|
82
|
-
#
|
82
|
+
# reflector.
|
83
83
|
# @return The newly-built reflector.
|
84
84
|
def build_reflector(options={})
|
85
85
|
reflector_kind = options.fetch(:reflector_kind, :REFLECTOR_A)
|
@@ -126,18 +126,18 @@ module RotorMachine
|
|
126
126
|
#
|
127
127
|
# The options hash can provide the following options:
|
128
128
|
#
|
129
|
-
# -
|
129
|
+
# - *:rotors* - An array of {Rotor} objects. This can be constructed
|
130
130
|
# manually, or through multiple calls to {#build_rotor}.
|
131
131
|
# Alternatively, you can pass an array of
|
132
132
|
# symbols which match the constants in the {Rotor} class, and {Rotor}
|
133
133
|
# objects will be built from those (using default position and step
|
134
134
|
# sizes).
|
135
135
|
#
|
136
|
-
# -
|
136
|
+
# - *:reflector* - A {Reflector} object. Alternatively, a symbol
|
137
137
|
# matching one of the reflector type constants can be passed in, and
|
138
138
|
# a {Reflector} of the specified type will be created.j
|
139
139
|
#
|
140
|
-
# -
|
140
|
+
# - *:connections* - A {Hash} of connections to make on the new {Machine}'s
|
141
141
|
# {Plugboard}.
|
142
142
|
#
|
143
143
|
# @param options The options for the newly built {Machine}.
|
data/rotor_machine.gemspec
CHANGED
@@ -1,33 +1,36 @@
|
|
1
1
|
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require 'rotor_machine/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'rotor_machine'
|
8
8
|
spec.version = RotorMachine::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Tammy Cravit']
|
10
|
+
spec.email = ['tammycravit@me.com']
|
11
|
+
spec.cert_chain = ['certs/tammycravit.pem']
|
12
|
+
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
|
11
13
|
|
12
14
|
spec.summary = %q{Simple Enigma-like rotor machine in Ruby}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
15
|
+
spec.homepage = 'https://github.com/tammycravit/rotor_machine'
|
16
|
+
spec.license = 'Apache-2.0'
|
15
17
|
|
16
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
19
|
f.match(%r{^(test|spec|features)/})
|
18
20
|
end
|
19
|
-
spec.bindir =
|
21
|
+
spec.bindir = 'exe'
|
20
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = [
|
23
|
+
spec.require_paths = ['lib']
|
22
24
|
|
23
|
-
spec.add_dependency
|
24
|
-
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
25
|
+
spec.add_dependency 'tcravit_ruby_lib'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'pry', '~> 0.11'
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
31
|
|
30
32
|
spec.add_development_dependency 'guard'
|
31
33
|
spec.add_development_dependency 'guard-rspec'
|
32
34
|
spec.add_development_dependency 'guard-bundler'
|
35
|
+
spec.add_development_dependency 'simplecov'
|
33
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,40 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rotor_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tammy Cravit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBh0YW1t
|
14
|
+
eWNyYXZpdC9EQz1tZS9EQz1jb20wHhcNMTgwMjE5MjMxNDQzWhcNMTkwMjE5MjMx
|
15
|
+
NDQzWjAjMSEwHwYDVQQDDBh0YW1teWNyYXZpdC9EQz1tZS9EQz1jb20wggGiMA0G
|
16
|
+
CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDDUddItdpGGMBoBfJZ2LWlXnfwEJWx
|
17
|
+
iOc478enSEQFOLXj3nVuTUhyac6MQFH6nB8CkNZt7MSokuWdQ7H//1Ajq+jeCwUm
|
18
|
+
WpjHF2BIL3WK7n8aAMH00p4gMAI4R8JnRjotmhUTIJCXtkIXoDTk1PGRzkH29q8+
|
19
|
+
dByUGmkAoX+iHqNRLbgiywLlpVapR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34
|
+
F9wFDQvW5Nv6grw3Unc9miwN6NHA5kEjKzDDSXzWKSzAWbqzlMp/FxD+zP7NuibT
|
35
|
+
pjZmBE7TzW3JK1L4mE7lBh9bwUC5WoyMBDPT7A==
|
36
|
+
-----END CERTIFICATE-----
|
37
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
12
38
|
dependencies:
|
13
39
|
- !ruby/object:Gem::Dependency
|
14
40
|
name: tcravit_ruby_lib
|
@@ -122,6 +148,20 @@ dependencies:
|
|
122
148
|
- - ">="
|
123
149
|
- !ruby/object:Gem::Version
|
124
150
|
version: '0'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: simplecov
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
type: :development
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
125
165
|
description:
|
126
166
|
email:
|
127
167
|
- tammycravit@me.com
|
@@ -143,6 +183,7 @@ files:
|
|
143
183
|
- Rakefile
|
144
184
|
- bin/console
|
145
185
|
- bin/setup
|
186
|
+
- certs/tammycravit.pem
|
146
187
|
- exe/rotor_machine
|
147
188
|
- images/Bundesarchiv_Enigma.jpg
|
148
189
|
- images/File:Enigma_wiring_kleur.png
|
@@ -175,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
216
|
version: '0'
|
176
217
|
requirements: []
|
177
218
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.7.
|
219
|
+
rubygems_version: 2.7.5
|
179
220
|
signing_key:
|
180
221
|
specification_version: 4
|
181
222
|
summary: Simple Enigma-like rotor machine in Ruby
|
metadata.gz.sig
ADDED
Binary file
|