2021-12-05 22:40:36 +01:00
|
|
|
#pragma once
|
2021-12-05 15:47:31 +01:00
|
|
|
#include <iostream>
|
2021-12-05 22:40:36 +01:00
|
|
|
#include "Util.h"
|
2021-12-06 00:39:58 +01:00
|
|
|
#include "FeistelMan.h"
|
2021-12-05 17:50:17 +01:00
|
|
|
|
2021-12-05 15:47:31 +01:00
|
|
|
int main()
|
|
|
|
{
|
2021-12-06 01:33:55 +01:00
|
|
|
// Load file to be encrypted
|
|
|
|
const Flexblock file = ReadFileToBits("images.jpg");
|
|
|
|
std::cout << "Finished reading..." << std::endl;
|
|
|
|
|
2021-12-06 00:39:58 +01:00
|
|
|
|
2021-12-06 01:33:55 +01:00
|
|
|
// Prepare cipher
|
|
|
|
FeistelMan feistel("Password yo");
|
2021-12-06 00:39:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Encrypt
|
2021-12-06 01:33:55 +01:00
|
|
|
const Flexblock ciphertext = feistel.Encipher(file, true);
|
|
|
|
//const std::string cipherHex = BitsToHexstring(ciphertext);
|
|
|
|
std::cout << "Finished encrypting..." << std::endl;
|
2021-12-06 00:39:58 +01:00
|
|
|
|
2021-12-06 01:33:55 +01:00
|
|
|
// Save encrypted file
|
|
|
|
WriteBitsToFile("encrypted.jpg", ciphertext);
|
|
|
|
std::cout << "Finished writing..." << std::endl;
|
2021-12-06 00:39:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Decrypt
|
2021-12-06 01:33:55 +01:00
|
|
|
//const Flexblock cleartextBits = feistel.Decipher(HexstringToBits(cipherHex));
|
|
|
|
const Flexblock cleartextBits = feistel.Decipher(ciphertext, true);
|
|
|
|
std::cout << "Finished decrypting..." << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
// Save decrypted file
|
|
|
|
WriteBitsToFile("decrypted.jpg", cleartextBits);
|
|
|
|
std::cout << "Finished writing..." << std::endl;
|
2021-12-05 19:26:58 +01:00
|
|
|
|
2021-12-05 22:40:36 +01:00
|
|
|
return 0;
|
2021-12-05 19:26:58 +01:00
|
|
|
}
|