-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
71 lines (58 loc) · 2.35 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <string>
#include "des/des.h"
#include "des3/des3.h"
#include "aes/aes.h"
#include "meta/ecb.h"
#include "meta/cbc.h"
#include "meta/cfb.h"
#include "meta/ofb.h"
#include "meta/ctr.h"
#include "sha256/sha256.h"
int main()
{
// DES & DES3 keys
std::string key_64 = "0001020304050607";
std::string key_64_2 = "0011223344556677";
std::string key_64_3 = "0021324354657687";
std::string key_arr[3] = {key_64, key_64_2, key_64_3};
// AES KEYS
std::string key_128 = "000102030405060708090a0b0c0d0e0f";
std::string key_192 = "000102030405060708090a0b0c0d0e0f1011121314151617";
std::string key_256 = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
// MESSAGES
std::string message = "00112233445566778899aabbccddeeff";
std::string message_ll = "00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff";
DES des;
des.generate_keys(key_64);
CTR<DES> ctr_des(des, 8);
std::cout << "\nDES in CTR mode" << std::endl;
std::cout << "Message: \n" << message << std::endl;
ctr_des.encrypt(message, 8);
std::cout << "Encrypted message: \n" << message << std::endl;
ctr_des.decrypt(message, 8);
std::cout << "Decrypted message: \n" << message << std::endl;
DES3 des3;
des3.generate_keys(key_arr);
OFB<DES3> ofb_des3(des3, 8);
std::cout << "\nTriple DES in OFB mode" << std::endl;
std::cout << "Message: \n" << message << std::endl;
ofb_des3.encrypt(message, 8);
std::cout << "Encrypted message: \n" << message << std::endl;
ofb_des3.decrypt(message, 8);
std::cout << "Decrypted message: \n" << message << std::endl;
AES aes(AES_key_length::AES_128);
aes.generate_keys(key_128);
CBC<AES> aes_ecb(aes, 16);
std::cout << "\nAES-128 in CBC mode" << std::endl;
std::cout << "Message: \n" << message_ll << std::endl;
aes_ecb.encrypt(message_ll, 16);
std::cout << "Encrypted message: \n" << message_ll << std::endl;
aes_ecb.decrypt(message_ll, 16);
std::cout << "Decrypted message: \n" << message_ll << std::endl;
std::string hash_str = "Testing input for the SHA256. Hash will be produced from this string.";
SHA256 sha256;
std::string out_hash = sha256.digest(hash_str);
std::cout << "\nSHA-256 input str: \n" << hash_str << "\nis: \n" << out_hash << std::endl;
return 0;
}