From 40764fe44d46d9fff01f6bacceeb5e41dd3b5531 Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Mon, 6 Dec 2021 10:07:15 +0100 Subject: [PATCH] Added optional parameter to print a progress report when ciphering files --- GhettoCrypt/GhettoCryptWrapper.cpp | 8 ++++---- GhettoCrypt/GhettoCryptWrapper.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GhettoCrypt/GhettoCryptWrapper.cpp b/GhettoCrypt/GhettoCryptWrapper.cpp index 6821782..031b88b 100644 --- a/GhettoCrypt/GhettoCryptWrapper.cpp +++ b/GhettoCrypt/GhettoCryptWrapper.cpp @@ -38,7 +38,7 @@ std::string GhettoCipher::GhettoCryptWrapper::DecryptString(const std::string& c 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 { @@ -49,7 +49,7 @@ bool GhettoCipher::GhettoCryptWrapper::EncryptFile(const std::string& filename_i Cipher cipher(password); // 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 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 { @@ -73,7 +73,7 @@ bool GhettoCipher::GhettoCryptWrapper::DecryptFile(const std::string& filename_i Cipher cipher(password); // 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 WriteBitsToFile(filename_out, cleartext_bits); diff --git a/GhettoCrypt/GhettoCryptWrapper.h b/GhettoCrypt/GhettoCryptWrapper.h index 430564f..6cae822 100644 --- a/GhettoCrypt/GhettoCryptWrapper.h +++ b/GhettoCrypt/GhettoCryptWrapper.h @@ -18,13 +18,13 @@ namespace GhettoCipher //! 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 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. //! 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 std::string& password); + static bool DecryptFile(const std::string& filename_in, const std::string& filename_out, const std::string& password, bool printProgressReport = false); private: // No instanciation! >:(