GCrypt/main.cpp

39 lines
991 B
C++
Raw Normal View History

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 01:38:43 +01:00
#include "GhettoCipher.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 01:33:55 +01:00
// Prepare cipher
2021-12-06 01:38:43 +01:00
GhettoCipher feistel("Password yo");
// 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 01:33:55 +01:00
// Save encrypted file
WriteBitsToFile("encrypted.jpg", ciphertext);
std::cout << "Finished writing..." << std::endl;
// 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 22:40:36 +01:00
return 0;
}