diff --git a/Feistel.vcxproj b/Feistel.vcxproj index 850438c..0161647 100644 --- a/Feistel.vcxproj +++ b/Feistel.vcxproj @@ -140,14 +140,14 @@ - + - + diff --git a/Feistel.vcxproj.filters b/Feistel.vcxproj.filters index 125b2e7..c16d76f 100644 --- a/Feistel.vcxproj.filters +++ b/Feistel.vcxproj.filters @@ -21,7 +21,7 @@ Quelldateien - + Quelldateien @@ -44,10 +44,10 @@ Headerdateien - + Headerdateien - + Headerdateien diff --git a/FeistelMan.cpp b/GhettoCipher.cpp similarity index 74% rename from FeistelMan.cpp rename to GhettoCipher.cpp index 1cd09cb..b79317d 100644 --- a/FeistelMan.cpp +++ b/GhettoCipher.cpp @@ -1,8 +1,8 @@ -#include "FeistelMan.h" +#include "GhettoCipher.h" #include "Util.h" #include -FeistelMan::FeistelMan(const Block& key) +GhettoCipher::GhettoCipher(const Block& key) : key { key } { @@ -10,14 +10,14 @@ FeistelMan::FeistelMan(const Block& key) return; } -FeistelMan::FeistelMan(const std::string& password) +GhettoCipher::GhettoCipher(const std::string& password) { key = PasswordToKey(password); return; } -FeistelMan::~FeistelMan() +GhettoCipher::~GhettoCipher() { // Clear key memory ZeroKeyMemory(); @@ -25,7 +25,7 @@ FeistelMan::~FeistelMan() return; } -void FeistelMan::SetKey(const Block& key) +void GhettoCipher::SetKey(const Block& key) { ZeroKeyMemory(); @@ -33,7 +33,7 @@ void FeistelMan::SetKey(const Block& key) return; } -void FeistelMan::SetPassword(const std::string& password) +void GhettoCipher::SetPassword(const std::string& password) { ZeroKeyMemory(); @@ -41,7 +41,7 @@ void FeistelMan::SetPassword(const std::string& password) return; } -Flexblock FeistelMan::Encipher(const Flexblock& data, bool printReports) const +Flexblock GhettoCipher::Encipher(const Flexblock& data, bool printProgress) const { // Split cleartext into blocks std::vector blocks; @@ -57,7 +57,7 @@ Flexblock FeistelMan::Encipher(const Flexblock& data, bool printReports) const for (std::size_t i = 0; i < blocks.size(); i++) { // Print reports if desired. If we have > 1000 blocks, print one report every 100 blocks. Otherwise for every 10th block. - if ((i % ((blocks.size() > 1000)? 100 : 10) == 0) && (printReports)) + if ((i % ((blocks.size() > 1000)? 100 : 10) == 0) && (printProgress)) std::cout << "Encrypting... (Block " << i << " / " << blocks.size() << " - " << ((float)i*100 / blocks.size()) << "\%)" << std::endl; const Block& lastBlock = (i>0) ? blocks[i-1] : emptyBlock; @@ -73,7 +73,7 @@ Flexblock FeistelMan::Encipher(const Flexblock& data, bool printReports) const return ss.str(); } -Flexblock FeistelMan::Decipher(const Flexblock& data, bool printReports) const +Flexblock GhettoCipher::Decipher(const Flexblock& data, bool printProgress) const { // Split ciphertext into blocks std::vector blocks; @@ -92,7 +92,7 @@ Flexblock FeistelMan::Decipher(const Flexblock& data, bool printReports) const for (std::size_t i = 0; i < blocks.size(); i++) { // Print reports if desired. If we have > 1000 blocks, print one report every 100 blocks. Otherwise for every 10th block. - if ((i % ((blocks.size() > 1000) ? 100 : 10) == 0) && (printReports)) + if ((i % ((blocks.size() > 1000) ? 100 : 10) == 0) && (printProgress)) std::cout << "Decrypting... (Block " << i << " / " << blocks.size() << " - " << ((float)i*100/ blocks.size()) << "\%)" << std::endl; Block tmpCopy = blocks[i]; @@ -112,11 +112,11 @@ Flexblock FeistelMan::Decipher(const Flexblock& data, bool printReports) const } #pragma optimize("", off ) -void FeistelMan::ZeroKeyMemory() +void GhettoCipher::ZeroKeyMemory() { key.reset(); return; } #pragma optimize("", on ) -const Block FeistelMan::emptyBlock; +const Block GhettoCipher::emptyBlock; diff --git a/FeistelMan.h b/GhettoCipher.h similarity index 56% rename from FeistelMan.h rename to GhettoCipher.h index dd4893f..8c99a52 100644 --- a/FeistelMan.h +++ b/GhettoCipher.h @@ -4,16 +4,16 @@ /** Class to apply a block cipher to messages of arbitrary length in a distributed manner */ -class FeistelMan +class GhettoCipher { public: - explicit FeistelMan(const Block& key); - explicit FeistelMan(const std::string& password); + explicit GhettoCipher(const Block& key); + explicit GhettoCipher(const std::string& password); - FeistelMan(const FeistelMan& other) = delete; - FeistelMan(FeistelMan&& other) noexcept = delete; + GhettoCipher(const GhettoCipher& other) = delete; + GhettoCipher(GhettoCipher&& other) noexcept = delete; - ~FeistelMan(); + ~GhettoCipher(); //! Will set the key void SetKey(const Block& key); @@ -22,10 +22,10 @@ public: void SetPassword(const std::string& password); //! Will encipher a flexblock of data - Flexblock Encipher(const Flexblock& data, bool printReports = false) const; + Flexblock Encipher(const Flexblock& data, bool printProgress = false) const; //! Will decipher a flexblock of data - Flexblock Decipher(const Flexblock& data, bool printReports = false) const; + Flexblock Decipher(const Flexblock& data, bool printProgress = false) const; private: Block key; diff --git a/decrypted.jpg b/decrypted.jpg new file mode 100644 index 0000000..0ac7a26 Binary files /dev/null and b/decrypted.jpg differ diff --git a/encrypted.jpg b/encrypted.jpg new file mode 100644 index 0000000..61c7143 Binary files /dev/null and b/encrypted.jpg differ diff --git a/images.jpg b/images.jpg new file mode 100644 index 0000000..d8f2fc7 Binary files /dev/null and b/images.jpg differ diff --git a/main.cpp b/main.cpp index 5d44a1b..ac16d34 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,7 @@ #pragma once #include #include "Util.h" -#include "FeistelMan.h" +#include "GhettoCipher.h" int main() { @@ -11,7 +11,7 @@ int main() // Prepare cipher - FeistelMan feistel("Password yo"); + GhettoCipher feistel("Password yo"); // Encrypt