Renamed class GCryptWrapper to GWrapper
This commit is contained in:
parent
cf784ca8ac
commit
bb76cbb2d7
@ -1,5 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <GCrypt/GCryptWrapper.h>
|
#include <GCrypt/GWrapper.h>
|
||||||
#include <GCrypt/SecureBitset.h>
|
#include <GCrypt/SecureBitset.h>
|
||||||
#include <GCrypt/Util.h>
|
#include <GCrypt/Util.h>
|
||||||
#include <GCrypt/InitializationVector.h>
|
#include <GCrypt/InitializationVector.h>
|
||||||
@ -14,11 +14,11 @@ void ExampleString() {
|
|||||||
std::cout << input << std::endl;
|
std::cout << input << std::endl;
|
||||||
|
|
||||||
// Encrypt
|
// Encrypt
|
||||||
const std::string encrypted = GCryptWrapper::EncryptString(input, "password1");
|
const std::string encrypted = GWrapper::EncryptString(input, "password1");
|
||||||
std::cout << encrypted << std::endl;
|
std::cout << encrypted << std::endl;
|
||||||
|
|
||||||
// Decrypt
|
// Decrypt
|
||||||
const std::string decrypted = GCryptWrapper::DecryptString(encrypted, "password1");
|
const std::string decrypted = GWrapper::DecryptString(encrypted, "password1");
|
||||||
std::cout << decrypted << std::endl;
|
std::cout << decrypted << std::endl;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -28,10 +28,10 @@ void ExampleFiles() {
|
|||||||
std::cout << "Example on how to encrypt & decrypt any file:" << std::endl;
|
std::cout << "Example on how to encrypt & decrypt any file:" << std::endl;
|
||||||
|
|
||||||
// Encrypt
|
// Encrypt
|
||||||
GCryptWrapper::EncryptFile("main.cpp", "main.cpp.crypt", "password1");
|
GWrapper::EncryptFile("main.cpp", "main.cpp.crypt", "password1");
|
||||||
|
|
||||||
// Decrypt
|
// Decrypt
|
||||||
GCryptWrapper::DecryptFile("main.cpp.crypt", "main.cpp.clear", "password1");
|
GWrapper::DecryptFile("main.cpp.crypt", "main.cpp.clear", "password1");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace Leonetienne::GCrypt {
|
|||||||
/** This class is a wrapper to make working with the GhettoCipher
|
/** This class is a wrapper to make working with the GhettoCipher
|
||||||
* super easy with a python-like syntax
|
* super easy with a python-like syntax
|
||||||
*/
|
*/
|
||||||
class GCryptWrapper {
|
class GWrapper {
|
||||||
public:
|
public:
|
||||||
//! Will encrypt a string and return it hexadecimally encoded.
|
//! Will encrypt a string and return it hexadecimally encoded.
|
||||||
static std::string EncryptString(const std::string& cleartext, const std::string& password);
|
static std::string EncryptString(const std::string& cleartext, const std::string& password);
|
||||||
@ -33,9 +33,8 @@ namespace Leonetienne::GCrypt {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
// No instanciation! >:(
|
// No instanciation! >:(
|
||||||
GCryptWrapper();
|
GWrapper();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
#include "GCrypt/GCryptWrapper.h"
|
#include "GCrypt/GWrapper.h"
|
||||||
#include "GCrypt/GCipher.h"
|
#include "GCrypt/GCipher.h"
|
||||||
#include "GCrypt/Util.h"
|
#include "GCrypt/Util.h"
|
||||||
|
|
||||||
namespace Leonetienne::GCrypt {
|
namespace Leonetienne::GCrypt {
|
||||||
|
|
||||||
std::string GCryptWrapper::EncryptString(const std::string& cleartext, const std::string& password) {
|
std::string GWrapper::EncryptString(const std::string& cleartext, const std::string& password) {
|
||||||
// Transform the password to a key
|
// Transform the password to a key
|
||||||
const Block key = PasswordToKey(password);
|
const Block key = PasswordToKey(password);
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ namespace Leonetienne::GCrypt {
|
|||||||
return ciphertext;
|
return ciphertext;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCryptWrapper::DecryptString(const std::string& ciphertext, const std::string& password) {
|
std::string GWrapper::DecryptString(const std::string& ciphertext, const std::string& password) {
|
||||||
// Transform the password to a key
|
// Transform the password to a key
|
||||||
const Block key = PasswordToKey(password);
|
const Block key = PasswordToKey(password);
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ namespace Leonetienne::GCrypt {
|
|||||||
return cleartext;
|
return cleartext;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GCryptWrapper::EncryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport) {
|
bool GWrapper::EncryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport) {
|
||||||
try {
|
try {
|
||||||
// Read the file to bits
|
// Read the file to bits
|
||||||
const Flexblock cleartext_bits = ReadFileToBits(filename_in);
|
const Flexblock cleartext_bits = ReadFileToBits(filename_in);
|
||||||
@ -59,7 +59,7 @@ namespace Leonetienne::GCrypt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GCryptWrapper::DecryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport) {
|
bool GWrapper::DecryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport) {
|
||||||
try {
|
try {
|
||||||
// Read the file to bits
|
// Read the file to bits
|
||||||
const Flexblock ciphertext_bits = ReadFileToBits(filename_in);
|
const Flexblock ciphertext_bits = ReadFileToBits(filename_in);
|
||||||
@ -80,7 +80,7 @@ namespace Leonetienne::GCrypt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Flexblock GCryptWrapper::CipherFlexblock(
|
Flexblock GWrapper::CipherFlexblock(
|
||||||
const Flexblock& data,
|
const Flexblock& data,
|
||||||
const Block& key,
|
const Block& key,
|
||||||
const GCipher::DIRECTION direction)
|
const GCipher::DIRECTION direction)
|
Loading…
x
Reference in New Issue
Block a user