Difference between revisions of "Enigma/primer"

From Teknologisk videncenter
Jump to: navigation, search
m (The software enigma)
m (The software enigma)
Line 8: Line 8:
 
=The software enigma=
 
=The software enigma=
 
In the software Enigma you would need some random Wheels and a Random Rotor Reftlector. For examle this three bit Enigma.
 
In the software Enigma you would need some random Wheels and a Random Rotor Reftlector. For examle this three bit Enigma.
<source lang=c>
+
== Three bit Example ==
/*  Input/output               0,  1,  2,  3,  4,  5,  6,  7 */
+
===Crypt===
byte wheel[2][8] = {
+
In the example below if the input=2 its send to Wheel 1 position 2 which output will be 1 and that's input for Wheel 2 which outputs 0 to the Reflector that outputs 7 as input for Reverse Wheel 2 which output's 2 as input for Reverse wheel 1 which Output 0 as the encrypted message.
/* Wheel 1 */               {  2,  7,  1,  5,  6,  3,  0,  4},
+
*2->1->0->7->2->0
/* Wheel 2 */               {  5,  0,  7,  2,  1,  6,  4,  3} };
+
<source lang=cli>
 +
Input                      0,  1,  <notice>2</notice>,  3,  4,  5,  6,  7
 +
Wheel 1                    2,  7,  <notice>1</notice>,  5,  6,  3,  0,  4
 +
Wheel 2                    5,  <notice>0</notice>,  7,  2,  1,  6,  4,  3
 +
Reflector                  <notice>7</notice>,  4,  6,  5,  1,  3,  2,  0
 +
Reverse wheel 2            1,  4,  3,  7,  6,  0,  5,  <notice>2</notice>
 +
Reverse wheel 1(output)    6,  2,  <notice>0</notice>,  5,  7,  3,  4,  1
 +
</source>
 +
===Decrypt===
 +
<source lang=cli>
 +
Input                      <notice>0</notice>,  1,  2,  3,  4,  5,  6,  7  
 +
Wheel 1                    <notice>2</notice>,  7,  1,  5,  6,  3,  0,  4
 +
Wheel 2                    5,  0,  <notice>7</notice>,  2,  1,  6,  4,  3
 +
Reflector                  7,  4,  6,  5,  1,  3,  2,  <notice>0</notice>
 +
Reverse wheel 2           <notice>1</notice>,  4,  3,  7,  6,  0,  5,  2
 +
Reverse wheel 1(output)    6,  <notice>2</notice>,  0,  5,  7,  3,  4,  1
 +
</source>
 +
===The wheel notch===
 +
Each time a letter/digit is encrypted/decrypted - same process - the Wheels are ticked forward.
 +
====Tick 1====
 +
Wheel 1 is ticked forward on every encryption/decryption. See below. When the Notch ticks from
 +
<source lang=cli>
 +
Input                      0,  1,  2,  3,  4,  5,  6,  7
 +
Wheel 1                    <notice>2,  7,  1,  5,  6,  3,  <error>0</error>,  4</notice>
 +
Wheel 2                    5,  0,  7,  2,  1,  6,  <error>4,</error>  3
 +
Reflector                  7,  4,  6,  5,  1,  3,  2,  0
 +
Reverse wheel 2            <notice>1,  4,  3,  7,  6,  0,  5,  2</notice>
 +
Reverse wheel 1(output)    6,  2,  0,  5,  7,  3,  4,  1
 +
</source>
 +
<source lang=cli>
 +
Input                      0,  1,  2,  3,  4,  5,  6,  7
 +
Wheel 1                    <notice>4,  2,  7,  1,  5,  6,  3,  <error>0</error></notice>
 +
Wheel 2                    5,  0,  7,  2,  1,  6,  <error>4</error>,  3
 +
Reflector                  7,  4,  6,  5,  1,  3,  2,  0
 +
Reverse wheel 2            1,  4,  3,  7,  6,  0,  5,  2
 +
Reverse wheel 1(output)    <notice>2,  0,  5,  7,  3,  4,  1,  6</notice>
 +
</source>
  
/* Notch array for wheels*/
 
byte wheel_notch[2] =      { 3, 6 };
 
  
byte rwheel[2][8] = {
+
{{Source cli}}
/* Reverse wheel 1 */      { 6,  2,  0,  5,  7,  3,  4,  1},
 
/* Reverse wheel 2 */      {  1,  4,  3,  7,  6,  0,  5,  2} };
 
 
 
/* Rotor reflector*/
 
byte rr[8] =                {  7,  4,  6,  5,  1,  3,  2,  0};
 
</source>
 
 
[[Category:CoE]]
 
[[Category:CoE]]

Revision as of 12:08, 5 December 2010

The Wheels

The Wheels can be installed in the Enigma in any sequence. If there are five different Wheels in total and the Enigma uses three Wheels. The total number of Wheel combinatins would be <math>5*4*3=60</math>

The actual mechanical Roters in a World War II Enigma. Notice Route Reflector B is installed
The scrambling action of the Enigma rotors are shown for two consecutive letters.

The software enigma

In the software Enigma you would need some random Wheels and a Random Rotor Reftlector. For examle this three bit Enigma.

Three bit Example

Crypt

In the example below if the input=2 its send to Wheel 1 position 2 which output will be 1 and that's input for Wheel 2 which outputs 0 to the Reflector that outputs 7 as input for Reverse Wheel 2 which output's 2 as input for Reverse wheel 1 which Output 0 as the encrypted message.

  • 2->1->0->7->2->0
Input                      0,   1,   <notice>2</notice>,   3,   4,   5,   6,   7 
Wheel 1                    2,   7,   <notice>1</notice>,   5,   6,   3,   0,   4
Wheel 2                    5,   <notice>0</notice>,   7,   2,   1,   6,   4,   3
Reflector                  <notice>7</notice>,   4,   6,   5,   1,   3,   2,   0
Reverse wheel 2            1,   4,   3,   7,   6,   0,   5,   <notice>2</notice>
Reverse wheel 1(output)    6,   2,   <notice>0</notice>,   5,   7,   3,   4,   1

Decrypt

Input                      <notice>0</notice>,   1,   2,   3,   4,   5,   6,   7 
Wheel 1                    <notice>2</notice>,   7,   1,   5,   6,   3,   0,   4
Wheel 2                    5,   0,   <notice>7</notice>,   2,   1,   6,   4,   3
Reflector                  7,   4,   6,   5,   1,   3,   2,   <notice>0</notice>
Reverse wheel 2            <notice>1</notice>,   4,   3,   7,   6,   0,   5,   2
Reverse wheel 1(output)    6,   <notice>2</notice>,   0,   5,   7,   3,   4,   1

The wheel notch

Each time a letter/digit is encrypted/decrypted - same process - the Wheels are ticked forward.

Tick 1

Wheel 1 is ticked forward on every encryption/decryption. See below. When the Notch ticks from

Input                      0,   1,   2,   3,   4,   5,   6,   7 
Wheel 1                    <notice>2,   7,   1,   5,   6,   3,   <error>0</error>,   4</notice>
Wheel 2                    5,   0,   7,   2,   1,   6,   <error>4,</error>   3
Reflector                  7,   4,   6,   5,   1,   3,   2,   0
Reverse wheel 2            <notice>1,   4,   3,   7,   6,   0,   5,   2</notice>
Reverse wheel 1(output)    6,   2,   0,   5,   7,   3,   4,   1
Input                      0,   1,   2,   3,   4,   5,   6,   7 
Wheel 1                    <notice>4,   2,   7,   1,   5,   6,   3,   <error>0</error></notice>
Wheel 2                    5,   0,   7,   2,   1,   6,   <error>4</error>,   3
Reflector                  7,   4,   6,   5,   1,   3,   2,   0
Reverse wheel 2            1,   4,   3,   7,   6,   0,   5,   2
Reverse wheel 1(output)    <notice>2,   0,   5,   7,   3,   4,   1,   6</notice>