Zoltan Hudak / Mbed OS Enigma_Hello

Dependencies:   Enigma

Revision:
2:ac7a3cea1757
Parent:
1:ad5fb6f2ab3c
Child:
3:83f583d06005
diff -r ad5fb6f2ab3c -r ac7a3cea1757 main.cpp
--- a/main.cpp	Mon Sep 23 07:50:57 2019 +0000
+++ b/main.cpp	Tue Sep 24 08:53:02 2019 +0000
@@ -3,7 +3,8 @@
 
 Serial      pc(USBTX, USBRX);
 DigitalOut  led1(LED1);
-Enigma      enigma(Enigma::ROTOR_IV, Enigma::ROTOR_I, Enigma::ROTOR_III, 126, 247, 14);
+uint8_t     plugboard[][2] = { { 4, 183 }, { 72, 247 }, { 108, 192 } }; // Define pairs of plugs connected with cords.
+Enigma      enigma(Enigma::ROTOR_IV, Enigma::ROTOR_I, Enigma::ROTOR_III, 126, 247, 14, plugboard, 3);
 
 /**
  * @brief
@@ -20,16 +21,17 @@
     // Helper functions for maintenance only:
     //enigma.genRotorWiring("IV", 213); // Generate new wiring for rotor IV.
     //enigma.genReflectorWiring(6);     // Generate new wiring for the reflector.
-
     while (true) {
         pc.printf("------------------------------\r\n");
+        // Print the 'message'.
         pc.printf("%s\r\n\r\n", message);
 
-        // Encrypt and print the encrypted message.
+        // Encrypt the 'message' and print.
         enigma.encrypt(encrypted, (uint8_t*)message, strlen(message));
         for (size_t i = 0; i < strlen(message); i++) {
             pc.putc(encrypted[i]);
         }
+
         pc.printf("\r\n\r\n");
 
         // Decrypt the 'encrypted' array and print.