rotor_machine 1.0.2 → 1.0.3

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: 011fe7fc1a9cf4f26639d4e2258e60ce349dcb47c33359f05e8b32e73dd4596b
4
- data.tar.gz: 4b1d95caac435efe137a1eb00d7c46dc110c293791f48fbf1cd958c7320fa47e
3
+ metadata.gz: a52da896d6dbf81dd24ef00e3f9c80c26b9cd48e64441d6be91e37b54710eb1e
4
+ data.tar.gz: af1fcf7f5cfc1786ae5b33e4c216f387b0d8345f76a270dc5428649ea1ba682f
5
5
  SHA512:
6
- metadata.gz: 00bfa80e329a8ede360f41e95211dba4584a38dfd0bd3de40446623e8f04061eb9b16af84d84e112f1bd8d2a2cb1856225f4425cbb86c6e3c9ba78cbe2b948ce
7
- data.tar.gz: 6fe91f3de47797f51e0867c6218c058dd1c33d01813ac63c5cb2d3bbf4d089a3fe712d7a685572cbee1f815f0e168f3c870da22d22a6f64e0c872d082b610f5a
6
+ metadata.gz: bb1878e52b14f84edfd06944815ec7bc97862823be50be3c497a959cfa9fc5f4d502759884568ac38e6e179de52c1f54868ca2650d4dd8033c85bba837a5e328
7
+ data.tar.gz: cf0017ad6357c67a4f1833bed242f20dbb770baee03c322b7c41e4fc4a8accdc743dde22d23b99b5e770a30d88e969611a3cf3a81621c8d0888acbc3d0bf1c2d
data/README.md CHANGED
@@ -1,10 +1,17 @@
1
1
  # RotorMachine
2
2
 
3
- The RotorMAchine gem provides a simple Ruby implementation of the [Enigma](https://en.wikipedia.org/wiki/Enigma_machine) rotor encryption machine.
3
+ The `RotorMachine` gem provides a simple Ruby implementation of the
4
+ [Enigma](https://en.wikipedia.org/wiki/Enigma_machine) rotor encryption machine.
4
5
 
5
- I wrote RotorMachine primarily as an exercise in Test-Driven Development with RSpec. It is not intended to be efficient or performant, and I wasn't striving much for idiomatic conciseness. My aims were fairly modular code and a relatively complete RSpec test suite.
6
+ I wrote RotorMachine primarily as an exercise in Test-Driven Development with
7
+ RSpec. It is not intended to be efficient or performant, and I wasn't striving much
8
+ for idiomatic conciseness. My aims were fairly modular code and a relatively
9
+ complete RSpec test suite.
6
10
 
7
- Many thanks to Kevin Sylvestre, whose [blog post](https://ksylvest.com/posts/2015-01-03/the-enigma-machine-using-ruby blog post) helped me understand some aspects of the internal workings of the Enigma and how the signals flowed through the pieces of the machine.
11
+ Many thanks to Kevin Sylvestre, whose
12
+ [blog post](https://ksylvest.com/posts/2015-01-03/the-enigma-machine-using-ruby blog post)
13
+ helped me understand some aspects of the internal workings of the Enigma and
14
+ how the signals flowed through the pieces of the machine.
8
15
 
9
16
  ## Installation
10
17
 
@@ -22,7 +29,7 @@ Or install it yourself as:
22
29
 
23
30
  $ gem install rotor_machine
24
31
 
25
- ## Usage
32
+ ## Architecture
26
33
 
27
34
  The `RotorMachine::Machine` class serves as the entrypoint and orchestrator for an Enigma machine.
28
35
 
@@ -81,7 +88,7 @@ One consequence of the Enigma's design is that a plaintext letter will
81
88
  never encipher to itself. The Allies were able to exploit this property
82
89
  to help break the Enigma's encryption in World War II.
83
90
 
84
- ### Usage
91
+ ## Usage
85
92
 
86
93
  To use the RotorMachine Enigma machine, you need to perform the following
87
94
  steps:
@@ -100,6 +107,35 @@ factory methods whcih set up, respectively, a fully configured machine
100
107
  with a default set of rotors and reflector, and an empty machine with
101
108
  no rotors or reflector.
102
109
 
110
+ ## Example
111
+
112
+ ```ruby
113
+ require 'rotor_machine'
114
+
115
+ machine = RotorMachine::Machine.empty_machine
116
+ machine.rotors << RotorMachine::Rotor.new(RotorMachine::Rotor::ROTOR_I, "A", 1)
117
+ machine.rotors << RotorMachine::Rotor.new(RotorMachine::Rotor::ROTOR_II, "A", 1)
118
+ machine.rotors << RotorMachine::Rotor.new(RotorMachine::Rotor::ROTOR_III, "A", 1)
119
+ machine.reflector = RotorMachine::Reflector.new(RotorMachine::Reflector::REFLECTOR_A)
120
+ machine.plugboard.connect("A", "M")
121
+ machine.plugboard.connect("Q", "K")
122
+
123
+ machine.set_rotors("CFL")
124
+ plaintext = "This is a super secret message".upcase
125
+ ciphertext = machine.encipher(plaintext) # => "MYGM AO I VVTDI QZXMGY AOGVIRJ"
126
+
127
+ machine.set_rotors("CFL")
128
+ new_plaintext = machine.encipher(ciphertext) # => "THIS IS A SUPER SECRET MESSAGE"
129
+
130
+ new_plaintext == plaintext # => true
131
+ ```
132
+
133
+ ## Documentation
134
+
135
+ The classes in `rotor_machine/lib/rotor_machine/*.rb` all contain doc comments that
136
+ pretty exhaustively describe their operation. The RSpec tests in the `spec/` directory
137
+ are also instructive for how the library works and how to use it.
138
+
103
139
  ## Development
104
140
 
105
141
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,4 +1,4 @@
1
1
  module RotorMachine
2
- VERSION_DATA = [1, 0, 2]
2
+ VERSION_DATA = [1, 0, 3]
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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tammy Cravit