comparison enigma/examples/example1.cpp @ 18:aa7a4298d609 0.1

Added a LICENSE, README, and an example.
author Brian Neal <bgneal@gmail.com>
date Wed, 11 Jul 2012 20:19:35 -0500
parents
children
comparison
equal deleted inserted replaced
17:b04dea5f71a3 18:aa7a4298d609
1 // Copyright (C) 2012 by Brian Neal.
2 // This file is part of Cpp-Enigma, the Enigma Machine simulation.
3 // Cpp-Enigma is released under the MIT License (see License.txt).
4 //
5 // example1.cpp - Quick example program showing usage.
6
7 #include <iostream>
8 #include <string>
9 #include "machine.h"
10
11 using namespace enigma;
12
13 int main()
14 {
15 // setup machine according to specs from a key sheet:
16
17 enigma_machine em({"II", "IV", "V"}, {1, 20, 11}, "B",
18 "AV BS CG DL FU HZ IN KM OW RX");
19
20 // set initial rotor starting position
21 em.set_display("WXC");
22
23 // decrypt the message key
24 const std::string msg_key = em.process_text("KCH");
25
26 // decrypt the ciphertext with the unencrypted message key
27 em.set_display(msg_key);
28
29 const std::string ciphertext("NIBLFMYMLLUFWCASCSSNVHAZ");
30 const std::string plaintext(em.process_text(ciphertext));
31
32 std::cout << plaintext << std::endl;
33 return 0;
34 }