rotor_machine 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca40c7b0bde73376d2432b9bbaf53889c2e221732e9bd9ae7f36ab7007cb1ded
4
- data.tar.gz: 72be1507e5a665d8bc5af4153121797824241761be5106d86deef1c6574be5a4
3
+ metadata.gz: 6e9e73f3f0d0dc5bf22074adf36c6232392581112ecddd4134ecdc4f64f6dc94
4
+ data.tar.gz: 934ff208c6cc22b67140633fdbca5f9b18c80a4c057448aad79b8c8859d3b562
5
5
  SHA512:
6
- metadata.gz: d9100dd5fb06326ec6dfad165c05c31a8e566f3e0645404358a263d1ad3eb7eb6b0e029149df61c727c85f13d811182a83ee3e1a5207540b512b91893421dc01
7
- data.tar.gz: 7a02cb6c72df3202d7c27a4df9560e1b41fbe203b34b101074f53ba0a3dacb4636f02a667bfcab9d4dc4c08c91a051fe95867b87505b1612b37a949725672698
6
+ metadata.gz: 4430444a33c8caf979d1854bb48539af1e3da74989a5da10a55cb21b6a415e7bdc46156fd5ee0cfc9c5153488f8667f9fa4e96e13d599236aae7028a96e10156
7
+ data.tar.gz: 0e4ffc2ff7a4ea276cc239d23a9b8bbf7fe1295f3dfc1376c3d23ed905cb04b4e3d04380fbfa8f8a9595c6c7f9800e4dabda9e434b104ccc4fa78b46cc049082
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # RotorMachine
2
2
 
3
+ ![German Enigma machine](https://github.com/tammycravit/rotor_machine/blob/master/images/Bundesarchiv_Enigma.jpg?raw=1)
4
+
3
5
  The `RotorMachine` gem provides a simple Ruby implementation of the
4
6
  [Enigma](https://en.wikipedia.org/wiki/Enigma_machine) rotor encryption machine.
5
7
 
@@ -31,26 +33,30 @@ Or install it yourself as:
31
33
 
32
34
  ## Architecture
33
35
 
34
- The `RotorMachine::Machine` class serves as the entrypoint and orchestrator for an Enigma machine.
36
+ The [`RotorMachine::Machine`](http://www.rubydoc.info/gems/rotor_machine/RotorMachine/Machine)
37
+ class serves as the entrypoint and orchestrator for an Enigma machine.
35
38
 
36
39
  ### Components of an Enigma machine
37
40
 
38
- The Enigma machine, as represented by the RotorMachine module, consists
39
- of the following components:
41
+ The Enigma machine, as represented by the [RotorMachine](http://www.rubydoc.info/gems/rotor_machine)
42
+ module, consists of the following components:
40
43
 
41
- * One or more rotors, which perform the transposition ciphering and also
42
- rotate to produce a polyalphabetic (rather than simple substitution)
43
- cipher.
44
+ * One or more [rotors](http://www.rubydoc.info/gems/rotor_machine/RotorMachine/Rotor), which
45
+ perform the transposition ciphering and also rotate to produce a polyalphabetic (rather
46
+ than simple substitution) cipher.
44
47
 
45
- * A reflector, which performs a simple symmetric substitution of letters
48
+ * A [reflector](http://www.rubydoc.info/gems/rotor_machine/RotorMachine/Reflector), which
49
+ performs a simple symmetric substitution of letters
46
50
 
47
- * A plugboard, which allows pairs of letters to be transposed on a
48
- per-message basis.
51
+ * A [plugboard](http://www.rubydoc.info/gems/rotor_machine/RotorMachine/Plugboard), which
52
+ allows pairs of letters to be transposed on a per-message basis.
49
53
 
50
- On an actual Enigma machine, these components are all electromechanical,
51
- and the Enigma also included a keyboard, a grid of lights to show the
52
- results, and in some cases a printer. Since this is a simulated Enigma,
53
- obviously, no keyboard/printer are supplied here.
54
+ On an actual Enigma machine, these components are all electromechanical, and
55
+ the Enigma also included a keyboard, a grid of lights to show the results, and
56
+ in some cases a printer. Since this is a simulated Enigma, obviously, no
57
+ keyboard/printer are supplied here. In this simulation, the
58
+ [Machine](http://www.rubydoc.info/gems/rotor_machine/RotorMachine/Machine)
59
+ class serves to encapsulate all of these components.
54
60
 
55
61
  The polyalphabetic encryption of the Enigma comes from the fact that the
56
62
  rotors are linked (mechanically in a real Enigma) so that they rotate
@@ -70,17 +76,19 @@ visit [https://en.wikipedia.org/wiki/Enigma_machine].
70
76
 
71
77
  ### The Signal Path of Letters
72
78
 
73
- On a physical Enigma machine, the electrical signal from a keypress is
74
- routed through the plugboard, then through each of the rotors in sequence
79
+ Here's a visual depiction of the signal path of a single character through
80
+ a (physical) Enigma machine:
81
+
82
+ ![Enigma signal path](https://github.com/tammycravit/rotor_machine/blob/master/images/File:Enigma_wiring_kleur.png?raw=1)
83
+
84
+ As you can see, the electrical signal from a keypress is routed through the
85
+ plugboard, then through each of the rotors in sequence
75
86
  from left to right. The signal then passes through the reflector (where it
76
87
  is transposed again), then back through the rotors in reverse order, and
77
88
  finally back through the plugboard a second time before being displayed on
78
89
  the light grid and/or printer.
79
-
80
- [https://commons.wikimedia.org/wiki/File:Enigma_wiring_kleur.svg] depicts
81
- this visually.
82
90
 
83
- One important consequence of this signal path is that encryption and
91
+ The result of the machine's signal path being a loop is that encryption and
84
92
  decryption are the same operation. That is to say, if you set the rotors
85
93
  and plugboard, and then type your plaintext into the machine, you'll get
86
94
  a string of ciphertext. If you then reset the machine to its initial state
@@ -116,12 +124,13 @@ no rotors or reflector.
116
124
  require 'rotor_machine'
117
125
 
118
126
  machine = RotorMachine::Machine.empty_machine
127
+
119
128
  machine.rotors << RotorMachine::Rotor.new(RotorMachine::Rotor::ROTOR_I, "A", 1)
120
129
  machine.rotors << RotorMachine::Rotor.new(RotorMachine::Rotor::ROTOR_II, "A", 1)
121
130
  machine.rotors << RotorMachine::Rotor.new(RotorMachine::Rotor::ROTOR_III, "A", 1)
122
131
  machine.reflector = RotorMachine::Reflector.new(RotorMachine::Reflector::REFLECTOR_A)
123
- machine.plugboard.connect("A", "M")
124
- machine.plugboard.connect("Q", "K")
132
+
133
+ machine.plugboard.connect("A", "M") machine.plugboard.connect("Q", "K")
125
134
 
126
135
  machine.set_rotors("CFL")
127
136
  plaintext = "This is a super secret message".upcase
@@ -135,9 +144,12 @@ new_plaintext == plaintext # => true
135
144
 
136
145
  ## Documentation
137
146
 
138
- The classes in `rotor_machine/lib/rotor_machine/*.rb` all contain doc comments that
139
- pretty exhaustively describe their operation. The RSpec tests in the `spec/` directory
140
- are also instructive for how the library works and how to use it.
147
+ The classes in
148
+ [`lib/rotor_machine/`](https://github.com/tammycravit/rotor_machine/tree/master/lib/rotor_machine)
149
+ all contain [documentation](http://www.rubydoc.info/gems/rotor_machine/) that
150
+ pretty exhaustively describe their operation.
151
+ The RSpec tests in the [`spec/`](https://github.com/tammycravit/rotor_machine/tree/master/spec)
152
+ directory are also instructive for how the library works and how to use it.
141
153
 
142
154
  ## Development
143
155
 
@@ -151,12 +163,14 @@ To release a new version, update the version number in `version.rb`, and then
151
163
  run `bundle exec rake release`, which will create a git tag for the version,
152
164
  push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
153
165
 
154
- This gem depends on the `tcravit_ruby_lib` gem, which provides Rake tasks to
155
- update the version number. You can use the `bundle exec rake version:bump:build`,
156
- `bundle exec version:bump:minor` and `bundle exec rake version:bump:major` tasks
157
- to increment the parts of the version number. (These tasks rewrite the file
158
- `lib/rotor_machine/version.rb`). After using them, you'll need to run a
159
- `git add lib/rotor_machine/version.rb` and `git commit -m "version bump"`.
166
+ This gem depends on the [`tcravit_ruby_lib`](https://github.com/tammycravit/tcravit_ruby_lib)
167
+ gem, which provides Rake tasks to update the version number. You can use the
168
+ `bundle exec rake version:bump:build`, `bundle exec version:bump:minor` and
169
+ `bundle exec rake version:bump:major` tasks to increment the parts of
170
+ the version number. (These tasks rewrite the file
171
+ [`lib/rotor_machine/version.rb`](https://github.com/tammycravit/rotor_machine/blob/master/lib/rotor_machine/version.rb).
172
+ After using them, you'll need to run a `git add lib/rotor_machine/version.rb`
173
+ and `git commit -m "version bump"`.
160
174
 
161
175
  ## Contributing
162
176
 
@@ -182,3 +196,11 @@ Everyone interacting in the RotorMachine project’s codebases, issue trackers,
182
196
  chat rooms and mailing lists is expected to follow the
183
197
  [code of conduct](https://github.com/tammycravit/rotor_machine/blob/master/CODE_OF_CONDUCT.md).
184
198
 
199
+ ## Image Credits
200
+
201
+ * Enigma image - from [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Bundesarchiv_Bild_183-2007-0705-502,_Chiffriermaschine_%22Enigma%22.jpg),
202
+ provided by Das Bundesarchiv (German Federal Archives).
203
+
204
+ * Enigma signal path image - from [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Enigma_wiring_kleur.svg),
205
+ by [MesserWoland](https://commons.wikimedia.org/wiki/User:MesserWoland)
206
+
Binary file
Binary file
@@ -1,4 +1,4 @@
1
1
  module RotorMachine
2
- VERSION_DATA = [1, 0, 6]
2
+ VERSION_DATA = [1, 0, 7]
3
3
  VERSION = VERSION_DATA.join(".")
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rotor_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tammy Cravit
@@ -100,6 +100,8 @@ files:
100
100
  - bin/console
101
101
  - bin/setup
102
102
  - exe/rotor_machine
103
+ - images/Bundesarchiv_Enigma.jpg
104
+ - images/File:Enigma_wiring_kleur.png
103
105
  - lib/rotor_machine.rb
104
106
  - lib/rotor_machine/machine.rb
105
107
  - lib/rotor_machine/plugboard.rb