Added optional parameter to print a progress report when ciphering files

This commit is contained in:
Leonetienne 2021-12-06 10:07:15 +01:00
parent d3ad38a7fa
commit 40764fe44d
2 changed files with 6 additions and 6 deletions

View File

@ -38,7 +38,7 @@ std::string GhettoCipher::GhettoCryptWrapper::DecryptString(const std::string& c
return cleartext; return cleartext;
} }
bool GhettoCipher::GhettoCryptWrapper::EncryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password) bool GhettoCipher::GhettoCryptWrapper::EncryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport)
{ {
try try
{ {
@ -49,7 +49,7 @@ bool GhettoCipher::GhettoCryptWrapper::EncryptFile(const std::string& filename_i
Cipher cipher(password); Cipher cipher(password);
// Encrypt our cleartext bits // Encrypt our cleartext bits
const Flexblock ciphertext_bits = cipher.Encipher(cleartext_bits); const Flexblock ciphertext_bits = cipher.Encipher(cleartext_bits, printProgressReport);
// Write our ciphertext bits to file // Write our ciphertext bits to file
WriteBitsToFile(filename_out, ciphertext_bits); WriteBitsToFile(filename_out, ciphertext_bits);
@ -62,7 +62,7 @@ bool GhettoCipher::GhettoCryptWrapper::EncryptFile(const std::string& filename_i
} }
} }
bool GhettoCipher::GhettoCryptWrapper::DecryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password) bool GhettoCipher::GhettoCryptWrapper::DecryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport)
{ {
try try
{ {
@ -73,7 +73,7 @@ bool GhettoCipher::GhettoCryptWrapper::DecryptFile(const std::string& filename_i
Cipher cipher(password); Cipher cipher(password);
// Decrypt the ciphertext bits // Decrypt the ciphertext bits
const Flexblock cleartext_bits = cipher.Decipher(ciphertext_bits); const Flexblock cleartext_bits = cipher.Decipher(ciphertext_bits, printProgressReport);
// Write our cleartext bits to file // Write our cleartext bits to file
WriteBitsToFile(filename_out, cleartext_bits); WriteBitsToFile(filename_out, cleartext_bits);

View File

@ -18,13 +18,13 @@ namespace GhettoCipher
//! Returns false if anything goes wrong (like, file-access). //! Returns false if anything goes wrong (like, file-access).
//! @filename_in The file to be read. //! @filename_in The file to be read.
//! @filename_out The file the encrypted version should be saved in. //! @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 std::string& password); static bool EncryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport = false);
//! Will decrypt a file. //! Will decrypt a file.
//! Returns false if anything goes wrong (like, file-access). //! Returns false if anything goes wrong (like, file-access).
//! @filename_in The file to be read. //! @filename_in The file to be read.
//! @filename_out The file the decrypted version should be saved in. //! @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 std::string& password); static bool DecryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport = false);
private: private:
// No instanciation! >:( // No instanciation! >:(