Remove 'using namespace std;'
[aes.git] / problem2.cpp
1 #include "aes.hpp"
2 #include <cstdio>
3
4 int main (int argc, char *argv[])
5 {
6         int i;
7
8         /* Read the Key */
9         byteArray key;
10
11         for (i=0; i<16; ++i)
12                 key.push_back (getchar());
13
14         /* Create the AES object */
15         AES aes (key);
16
17         /* Read all characters of input */
18         byteArray input;
19
20         for (char c=getchar(); c != EOF; c=getchar())
21         {
22                 input.push_back (c);
23
24                 if (input.size() == 16)
25                 {
26                         byteArray ciphertext = aes.encrypt (input);
27                         byteArray plaintext  = aes.decrypt (ciphertext);
28
29                         /* Print it */
30                         for (i=0; i<plaintext.size(); ++i)
31                                 std::printf ("%c", plaintext.at(i));
32
33                         input.clear();
34                 }
35
36         }
37
38         return 0;
39 }
40
41 /* vim: set ts=4 sts=4 sw=4 noet tw=120 nowrap: */