bgneal@18: // Copyright (C) 2012 by Brian Neal. bgneal@18: // This file is part of Cpp-Enigma, the Enigma Machine simulation. bgneal@18: // Cpp-Enigma is released under the MIT License (see License.txt). bgneal@18: // bgneal@18: // example1.cpp - Quick example program showing usage. bgneal@18: bgneal@18: #include bgneal@18: #include bgneal@18: #include "machine.h" bgneal@18: bgneal@18: using namespace enigma; bgneal@18: bgneal@18: int main() bgneal@18: { bgneal@18: // setup machine according to specs from a key sheet: bgneal@18: bgneal@18: enigma_machine em({"II", "IV", "V"}, {1, 20, 11}, "B", bgneal@18: "AV BS CG DL FU HZ IN KM OW RX"); bgneal@18: bgneal@18: // set initial rotor starting position bgneal@18: em.set_display("WXC"); bgneal@18: bgneal@18: // decrypt the message key bgneal@18: const std::string msg_key = em.process_text("KCH"); bgneal@18: bgneal@18: // decrypt the ciphertext with the unencrypted message key bgneal@18: em.set_display(msg_key); bgneal@18: bgneal@18: const std::string ciphertext("NIBLFMYMLLUFWCASCSSNVHAZ"); bgneal@18: const std::string plaintext(em.process_text(ciphertext)); bgneal@18: bgneal@18: std::cout << plaintext << std::endl; bgneal@18: return 0; bgneal@18: }