5 static void print_by_16s (const byteArray b, std::string name)
9 std::cout << "Printing: " << name << "\n" << std::endl;
11 for (i=0; i<b.size()/16; ++i)
14 std::printf ("%.2x ", b.at(i*16+j));
21 int main (int argc, char *argv[])
36 key.push_back (getchar());
38 /* Create the AES object */
41 /* Read all characters of input */
44 for (char c=getchar(); c != EOF; c=getchar())
48 if (input.size() == 16)
50 byteArray ciphertext = aes.encrypt (input);
51 byteArray plaintext = aes.decrypt (ciphertext);
54 for (i=0; i<plaintext.size(); ++i)
55 std::printf ("%c", plaintext.at(i));
64 std::ifstream fin ("Problem3.out", ios::binary);
70 key.push_back (fin.get());
72 /* Create the AES Object */
77 /* Read the input and decrypt */
78 for (char c=fin.get(); !fin.eof(); c=fin.get())
82 if (input.size() == 16)
84 byteArray plaintext = aes.decrypt (input);
87 for (i=0; i<plaintext.size(); ++i)
88 std::printf ("%c", plaintext.at(i));
96 const int inputSize = 4096;
98 byteArray key (16, 2);
99 byteArray input (inputSize, 0);
102 for (i=0; i<inputSize; ++i)
107 print_by_16s (input, "Input");
109 byteArray ciphertext = aes.encrypt (input);
111 print_by_16s (ciphertext, "Ciphertext");
113 byteArray plaintext = aes.decrypt (ciphertext);
115 print_by_16s (plaintext, "Plaintext");
121 byteArray key (16, 0);
126 print_by_16s (key, "Key");
128 byteArray plaintext (16, 0);
131 plaintext.at (i) = (i << 4) | i;
133 print_by_16s (plaintext, "Plaintext");
137 byteArray ciphertext = aes.encrypt (plaintext);
139 print_by_16s (ciphertext, "Ciphertext");
146 /* vim: set ts=4 sts=4 sw=4 noet tw=120 nowrap: */