GCrypt/GCryptLib/exec/main.cpp

46 lines
1.1 KiB
C++
Raw Normal View History

#include <iostream>
#include <GCrypt/GCryptWrapper.h>
2022-05-16 22:35:28 +02:00
#include <GCrypt/SecureBitset.h>
#include <GCrypt/Util.h>
#include <GCrypt/InitializationVector.h>
using namespace Leonetienne::GCrypt;
2022-05-16 22:01:52 +02:00
void ExampleString() {
std::cout << "Example on how to encrypt & decrypt a string:" << std::endl;
2022-05-16 22:01:52 +02:00
// Get some string
const std::string input = "I am a super secret message!";
std::cout << input << std::endl;
2022-05-16 22:01:52 +02:00
// Encrypt
const std::string encrypted = GCryptWrapper::EncryptString(input, "password1");
2022-05-16 22:01:52 +02:00
std::cout << encrypted << std::endl;
2022-05-16 22:01:52 +02:00
// Decrypt
const std::string decrypted = GCryptWrapper::DecryptString(encrypted, "password1");
2022-05-16 22:01:52 +02:00
std::cout << decrypted << std::endl;
return;
}
2022-05-16 22:01:52 +02:00
void ExampleFiles() {
std::cout << "Example on how to encrypt & decrypt any file:" << std::endl;
2022-05-16 22:01:52 +02:00
// Encrypt
GCryptWrapper::EncryptFile("main.cpp", "main.cpp.crypt", "password1");
2022-05-16 22:01:52 +02:00
// Decrypt
GCryptWrapper::DecryptFile("main.cpp.crypt", "main.cpp.clear", "password1");
2022-05-16 22:01:52 +02:00
return;
}
2022-05-16 22:01:52 +02:00
int main() {
ExampleString();
//ExampleFiles();
2022-05-16 22:01:52 +02:00
return 0;
}
2022-05-16 22:01:52 +02:00