2022-05-22 13:45:40 +02:00

43 lines
1.5 KiB
C++

#pragma once
#include <string>
#include "GCrypt/Flexblock.h"
#include "GCrypt/Block.h"
#include "GCrypt/GCipher.h"
#include "GCrypt/Key.h"
namespace Leonetienne::GCrypt {
/** This class is a wrapper to make working with the GhettoCipher
* super easy with a python-like syntax
*/
class GWrapper {
public:
//! Will encrypt a string and return it hexadecimally encoded.
static std::string EncryptString(const std::string& cleartext, const Key& key);
//! Will decrypt a hexadecimally encoded string.
static std::string DecryptString(const std::string& ciphertext, const Key& key);
//! Will encrypt a file.
//! Returns false if anything goes wrong (like, file-access).
//! @filename_in The file to be read.
//! @filename_out The file the encrypted version should be saved in.
static bool EncryptFile(const std::string& filename_in, const std::string& filename_out, const Key& key, bool printProgressReport = false);
//! Will decrypt a file.
//! Returns false if anything goes wrong (like, file-access).
//! @filename_in The file to be read.
//! @filename_out The file the decrypted version should be saved in.
static bool DecryptFile(const std::string& filename_in, const std::string& filename_out, const Key& key, bool printProgressReport = false);
//! Will enncrypt or decrypt an entire flexblock of binary data, given a key.
static Flexblock CipherFlexblock(const Flexblock& data, const Key& key, const GCipher::DIRECTION direction);
private:
// No instanciation! >:(
GWrapper();
};
}