GCrypt/GCryptLib/exec/main.cpp

47 lines
1.2 KiB
C++
Raw Normal View History

#include <iostream>
#include <GCrypt/GWrapper.h>
2022-05-16 22:35:28 +02:00
#include <GCrypt/SecureBitset.h>
#include <GCrypt/Util.h>
#include <GCrypt/InitializationVector.h>
2022-05-22 13:43:23 +02:00
#include <GCrypt/Key.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
2022-05-22 13:43:23 +02:00
const std::string encrypted = GWrapper::EncryptString(input, Key::FromPassword("password1"));
2022-05-16 22:01:52 +02:00
std::cout << encrypted << std::endl;
2022-05-16 22:01:52 +02:00
// Decrypt
2022-05-22 13:43:23 +02:00
const std::string decrypted = GWrapper::DecryptString(encrypted, Key::FromPassword("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
2022-05-22 13:43:23 +02:00
GWrapper::EncryptFile("main.cpp", "main.cpp.crypt", Key::FromPassword("password1"));
2022-05-16 22:01:52 +02:00
// Decrypt
2022-05-22 13:43:23 +02:00
GWrapper::DecryptFile("main.cpp.crypt", "main.cpp.clear", Key::FromPassword("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