From 136cdb605f1731261760909a45b5755e488ac68f Mon Sep 17 00:00:00 2001 From: kimci86 Date: Sun, 25 Feb 2024 15:27:03 +0100 Subject: [PATCH] Switch to trailing return type style --- include/Arguments.hpp | 20 ++++++++++---------- include/Attack.hpp | 4 ++-- include/Crc32Tab.hpp | 8 ++++---- include/Keys.hpp | 8 ++++---- include/KeystreamTab.hpp | 6 +++--- include/MultTab.hpp | 8 ++++---- include/SigintHandler.hpp | 2 +- include/Zip.hpp | 26 +++++++++++++------------- include/Zreduction.hpp | 4 ++-- include/file.hpp | 8 ++++---- include/log.hpp | 4 ++-- include/password.hpp | 6 +++--- include/types.hpp | 4 ++-- src/Arguments.cpp | 28 ++++++++++++++-------------- src/Attack.cpp | 4 ++-- src/Data.cpp | 4 ++-- src/Zip.cpp | 22 +++++++++++----------- src/Zreduction.cpp | 4 ++-- src/file.cpp | 8 ++++---- src/log.cpp | 4 ++-- src/main.cpp | 6 +++--- src/password.cpp | 6 +++--- 22 files changed, 97 insertions(+), 97 deletions(-) diff --git a/include/Arguments.hpp b/include/Arguments.hpp index f12a2f6..76251e0 100644 --- a/include/Arguments.hpp +++ b/include/Arguments.hpp @@ -29,7 +29,7 @@ class Arguments /// \exception FileError if a file cannot be opened /// \exception ZipError if a zip entry cannot be opened /// \exception Data::Error if the loaded data cannot be used to carry out an attack - Data loadData() const; + auto loadData() const -> Data; std::optional cipherFile; ///< File containing the ciphertext std::optional cipherIndex; ///< Index of the zip entry containing ciphertext @@ -104,7 +104,7 @@ class Arguments std::size_t maxLength{std::numeric_limits::max()}; /// Compute the intersection between this interval and the given \a other interval - LengthInterval operator&(const LengthInterval& other) const; + auto operator&(const LengthInterval& other) const -> LengthInterval; }; /// \copydoc LengthInterval std::optional length; @@ -131,7 +131,7 @@ class Arguments const char** m_current; const char** const m_end; - bool finished() const; + auto finished() const -> bool; void parseArgument(); @@ -165,13 +165,13 @@ class Arguments help }; - std::string readString(const std::string& description); - Option readOption(const std::string& description); - int readInt(const std::string& description); - std::size_t readSize(const std::string& description); - std::vector readHex(const std::string& description); - std::uint32_t readKey(const std::string& description); - std::vector readCharset(); + auto readString(const std::string& description) -> std::string; + auto readOption(const std::string& description) -> Option; + auto readInt(const std::string& description) -> int; + auto readSize(const std::string& description) -> std::size_t; + auto readHex(const std::string& description) -> std::vector; + auto readKey(const std::string& description) -> std::uint32_t; + auto readCharset() -> std::vector; }; #endif // BKCRACK_ARGUMENTS_HPP diff --git a/include/Attack.hpp b/include/Attack.hpp index 0dcc2c1..651f8d1 100644 --- a/include/Attack.hpp +++ b/include/Attack.hpp @@ -68,7 +68,7 @@ class Attack /// \param exhaustive True to try and find all valid keys, /// false to stop searching after the first one is found /// \param progress Object to report progress -std::vector attack(const Data& data, const std::vector& zi_2_32_vector, int& start, - std::size_t index, int jobs, bool exhaustive, Progress& progress); +auto attack(const Data& data, const std::vector& zi_2_32_vector, int& start, std::size_t index, int jobs, + bool exhaustive, Progress& progress) -> std::vector; #endif // BKCRACK_ATTACK_HPP diff --git a/include/Crc32Tab.hpp b/include/Crc32Tab.hpp index a78eae9..3cd2407 100644 --- a/include/Crc32Tab.hpp +++ b/include/Crc32Tab.hpp @@ -8,25 +8,25 @@ class Crc32Tab { public: /// \return CRC32 using a lookup table - static std::uint32_t crc32(std::uint32_t pval, std::uint8_t b) + static auto crc32(std::uint32_t pval, std::uint8_t b) -> std::uint32_t { return pval >> 8 ^ instance.crctab[lsb(pval) ^ b]; } /// \return CRC32^-1 using a lookup table - static std::uint32_t crc32inv(std::uint32_t crc, std::uint8_t b) + static auto crc32inv(std::uint32_t crc, std::uint8_t b) -> std::uint32_t { return crc << 8 ^ instance.crcinvtab[msb(crc)] ^ b; } /// \return Yi[24,32) from Zi and Z{i-1} using CRC32^-1 - static std::uint32_t getYi_24_32(std::uint32_t zi, std::uint32_t zim1) + static auto getYi_24_32(std::uint32_t zi, std::uint32_t zim1) -> std::uint32_t { return (crc32inv(zi, 0) ^ zim1) << 24; } /// \return Z{i-1}[10,32) from Zi[2,32) using CRC32^-1 - static std::uint32_t getZim1_10_32(std::uint32_t zi_2_32) + static auto getZim1_10_32(std::uint32_t zi_2_32) -> std::uint32_t { return crc32inv(zi_2_32, 0) & mask<10, 32>; // discard 10 least significant bits } diff --git a/include/Keys.hpp b/include/Keys.hpp index c19cc1e..7b0fb5e 100644 --- a/include/Keys.hpp +++ b/include/Keys.hpp @@ -49,25 +49,25 @@ class Keys void updateBackward(const std::vector& ciphertext, std::size_t current, std::size_t target); /// \return X value - std::uint32_t getX() const + auto getX() const -> std::uint32_t { return x; } /// \return Y value - std::uint32_t getY() const + auto getY() const -> std::uint32_t { return y; } /// \return Z value - std::uint32_t getZ() const + auto getZ() const -> std::uint32_t { return z; } /// \return the keystream byte derived from the keys - std::uint8_t getK() const + auto getK() const -> std::uint8_t { return KeystreamTab::getByte(z); } diff --git a/include/KeystreamTab.hpp b/include/KeystreamTab.hpp index da876dc..9eaf80a 100644 --- a/include/KeystreamTab.hpp +++ b/include/KeystreamTab.hpp @@ -11,7 +11,7 @@ class KeystreamTab public: /// \return the keystream byte ki associated to a Zi value /// \note Only Zi[2,16) is used - static std::uint8_t getByte(std::uint32_t zi) + static auto getByte(std::uint32_t zi) -> std::uint8_t { return instance.keystreamtab[(zi & mask<0, 16>) >> 2]; } @@ -19,14 +19,14 @@ class KeystreamTab /// \return a vector of Zi[2,16) values having given [10,16) bits /// such that getByte(zi) is equal to ki /// \note the vector contains one element on average - static const std::vector& getZi_2_16_vector(std::uint8_t ki, std::uint32_t zi_10_16) + static auto getZi_2_16_vector(std::uint8_t ki, std::uint32_t zi_10_16) -> const std::vector& { return instance.keystreaminvfiltertab[ki][(zi_10_16 & mask<0, 16>) >> 10]; } /// \return true if the vector returned by getZi_2_16_vector is not empty, /// false otherwise - static bool hasZi_2_16(std::uint8_t ki, std::uint32_t zi_10_16) + static auto hasZi_2_16(std::uint8_t ki, std::uint32_t zi_10_16) -> bool { return instance.keystreaminvexists[ki][(zi_10_16 & mask<0, 16>) >> 10]; } diff --git a/include/MultTab.hpp b/include/MultTab.hpp index d33a928..c9a0380 100644 --- a/include/MultTab.hpp +++ b/include/MultTab.hpp @@ -8,27 +8,27 @@ class MultTab { public: /// \return mult * x using a lookup table - static std::uint32_t getMult(std::uint8_t x) + static auto getMult(std::uint8_t x) -> std::uint32_t { return instance.multtab[x]; } /// \return mult^-1 * x using a lookup table - static std::uint32_t getMultinv(std::uint8_t x) + static auto getMultinv(std::uint8_t x) -> std::uint32_t { return instance.multinvtab[x]; } /// \return a vector of bytes x such that /// msb(x*mult^-1) is equal to msbprod or msbprod-1 - static const std::vector& getMsbProdFiber2(std::uint8_t msbprodinv) + static auto getMsbProdFiber2(std::uint8_t msbprodinv) -> const std::vector& { return instance.msbprodfiber2[msbprodinv]; } /// \return a vector of bytes x such that /// msb(x*mult^-1) is equal to msbprod, msbprod-1 or msbprod+1 - static const std::vector& getMsbProdFiber3(std::uint8_t msbprodinv) + static auto getMsbProdFiber3(std::uint8_t msbprodinv) -> const std::vector& { return instance.msbprodfiber3[msbprodinv]; } diff --git a/include/SigintHandler.hpp b/include/SigintHandler.hpp index 84836e7..64d2d54 100644 --- a/include/SigintHandler.hpp +++ b/include/SigintHandler.hpp @@ -19,7 +19,7 @@ class SigintHandler SigintHandler(const SigintHandler& other) = delete; /// Deleted assignment operator - SigintHandler& operator=(const SigintHandler& other) = delete; + auto operator=(const SigintHandler& other) -> SigintHandler& = delete; }; #endif // BKCRACK_SIGINTHANDLER_HPP diff --git a/include/Zip.hpp b/include/Zip.hpp index 2bd2e8c..861c2b2 100644 --- a/include/Zip.hpp +++ b/include/Zip.hpp @@ -89,33 +89,33 @@ class Zip /// \brief Get the current entry /// \pre The iterator must be valid - const Entry& operator*() const + auto operator*() const -> const Entry& { return *m_entry; } /// \brief Access a member of the current entry /// \pre The iterator must be valid - const Entry* operator->() const + auto operator->() const -> const Entry* { return &(*m_entry); } /// \brief Read the next central directory record if any or assign end-of-stream iterator /// \pre The iterator must be valid - Iterator& operator++(); + auto operator++() -> Iterator&; /// \copydoc operator++ - Iterator operator++(int); + auto operator++(int) -> Iterator; /// Test if iterators are equivalent, i.e. both are end-of-stream or both are valid - bool operator==(const Zip::Iterator& other) const + auto operator==(const Zip::Iterator& other) const -> bool { return (m_is == nullptr) == (other.m_is == nullptr); } /// Test if iterators are not equivalent - bool operator!=(const Zip::Iterator& other) const + auto operator!=(const Zip::Iterator& other) const -> bool { return !(*this == other); } @@ -135,24 +135,24 @@ class Zip explicit Zip(const std::string& filename); /// Get an iterator pointing to the first entry - Iterator begin() const + auto begin() const -> Iterator { return Iterator{*this}; } /// Get an end-of-stream iterator - Iterator end() const + auto end() const -> Iterator { return Iterator{}; } /// \brief Get the first entry having the given name /// \exception Error if the archive does not contain an entry with the given name - Entry operator[](const std::string& name) const; + auto operator[](const std::string& name) const -> Entry; /// \brief Get the entry at the given index /// \exception Error if the index is out of bounds - Entry operator[](std::size_t index) const; + auto operator[](std::size_t index) const -> Entry; /// \brief Check that the given entry uses the expected encryption algorithm /// \exception Error if the given entry does not use the expected encryption algorithm @@ -160,12 +160,12 @@ class Zip /// \brief Set the underlying stream's input position indicator at the beginning the given entry's raw data /// \exception Error if the given entry's data is not at the expected offset - std::istream& seek(const Entry& entry) const; + auto seek(const Entry& entry) const -> std::istream&; /// \brief Load at most \a count bytes of the given entry's raw data /// \exception Error if the given entry's data is not at the expected offset - std::vector load(const Entry& entry, - std::size_t count = std::numeric_limits::max()) const; + auto load(const Entry& entry, std::size_t count = std::numeric_limits::max()) const + -> std::vector; /// \brief Copy the zip file into \a os changing the encrypted data using the given keys /// \exception Error if the archive is not a valid zip archive diff --git a/include/Zreduction.hpp b/include/Zreduction.hpp index a9b74cc..19ab1f9 100644 --- a/include/Zreduction.hpp +++ b/include/Zreduction.hpp @@ -18,10 +18,10 @@ class Zreduction void generate(); /// \return the generated Zi[2,32) values - const std::vector& getCandidates() const; + auto getCandidates() const -> const std::vector&; /// \return the index of the Zi[2,32) values relative to keystream - std::size_t getIndex() const; + auto getIndex() const -> std::size_t; private: const std::vector& keystream; diff --git a/include/file.hpp b/include/file.hpp index df94eba..a2cb0ad 100644 --- a/include/file.hpp +++ b/include/file.hpp @@ -36,17 +36,17 @@ class FileError : public BaseError /// \brief Open an input file stream /// \exception FileError if the file cannot be opened -std::ifstream openInput(const std::string& filename); +auto openInput(const std::string& filename) -> std::ifstream; /// Load at most \a size bytes from an input stream -std::vector loadStream(std::istream& is, std::size_t size); +auto loadStream(std::istream& is, std::size_t size) -> std::vector; /// \brief Load at most \a size bytes from a file /// \exception FileError if the file cannot be opened -std::vector loadFile(const std::string& filename, std::size_t size); +auto loadFile(const std::string& filename, std::size_t size) -> std::vector; /// \brief Open an output file stream /// \exception FileError if the file cannot be opened -std::ofstream openOutput(const std::string& filename); +auto openOutput(const std::string& filename) -> std::ofstream; #endif // BKCRACK_FILE_HPP diff --git a/include/log.hpp b/include/log.hpp index bdaea9d..f6351b3 100644 --- a/include/log.hpp +++ b/include/log.hpp @@ -7,12 +7,12 @@ /// \brief Output stream manipulators /// Insert the current local time into the output stream -std::ostream& put_time(std::ostream& os); +auto put_time(std::ostream& os) -> std::ostream&; class Keys; // forward declaration /// \brief Insert a representation of keys into the stream \a os /// \relates Keys -std::ostream& operator<<(std::ostream& os, const Keys& keys); +auto operator<<(std::ostream& os, const Keys& keys) -> std::ostream&; #endif // BKCRACK_LOG_HPP diff --git a/include/password.hpp b/include/password.hpp index 58cc34e..cd56d63 100644 --- a/include/password.hpp +++ b/include/password.hpp @@ -85,8 +85,8 @@ class Recovery /// \return A vector of passwords associated with the given keys. /// A vector is needed instead of a single string because there can be /// collisions (i.e. several passwords for the same keys). -std::vector recoverPassword(const Keys& keys, const std::vector& charset, - std::size_t minLength, std::size_t maxLength, std::string& start, int jobs, - bool exhaustive, Progress& progress); +auto recoverPassword(const Keys& keys, const std::vector& charset, std::size_t minLength, + std::size_t maxLength, std::string& start, int jobs, bool exhaustive, Progress& progress) + -> std::vector; #endif // BKCRACK_PASSWORD_HPP diff --git a/include/types.hpp b/include/types.hpp index f855886..2d3eb21 100644 --- a/include/types.hpp +++ b/include/types.hpp @@ -21,13 +21,13 @@ class BaseError : public std::runtime_error // utility functions /// \return the least significant byte of x -constexpr std::uint8_t lsb(std::uint32_t x) +constexpr auto lsb(std::uint32_t x) -> std::uint8_t { return x; } /// \return the most significant byte of x -constexpr std::uint8_t msb(std::uint32_t x) +constexpr auto msb(std::uint32_t x) -> std::uint8_t { return x >> 24; } diff --git a/src/Arguments.cpp b/src/Arguments.cpp index b3feec2..b81af73 100644 --- a/src/Arguments.cpp +++ b/src/Arguments.cpp @@ -12,7 +12,7 @@ namespace { -std::bitset<256> charRange(char first, char last) +auto charRange(char first, char last) -> std::bitset<256> { std::bitset<256> bitset; @@ -41,17 +41,17 @@ auto translateIntParseError(F&& f, const std::string& value) } } -int parseInt(const std::string& value) +auto parseInt(const std::string& value) -> int { return translateIntParseError([](const std::string& value) { return std::stoi(value, nullptr, 0); }, value); } -std::size_t parseSize(const std::string& value) +auto parseSize(const std::string& value) -> std::size_t { return translateIntParseError([](const std::string& value) { return std::stoull(value, nullptr, 0); }, value); } -std::variant parseInterval(const std::string& value) +auto parseInterval(const std::string& value) -> std::variant { const std::string separator = ".."; @@ -145,7 +145,7 @@ Arguments::Arguments(int argc, const char* argv[]) throw Error("--bruteforce parameter is missing (required by --length)"); } -Data Arguments::loadData() const +auto Arguments::loadData() const -> Data { // load known plaintext std::vector plaintext; @@ -188,12 +188,12 @@ Data Arguments::loadData() const extraPlaintextWithCheckByte.value_or(extraPlaintext)); } -Arguments::LengthInterval Arguments::LengthInterval::operator&(const Arguments::LengthInterval& other) const +auto Arguments::LengthInterval::operator&(const Arguments::LengthInterval& other) const -> Arguments::LengthInterval { return {std::max(minLength, other.minLength), std::min(maxLength, other.maxLength)}; } -bool Arguments::finished() const +auto Arguments::finished() const -> bool { return m_current == m_end; } @@ -309,7 +309,7 @@ void Arguments::parseArgument() } } -std::string Arguments::readString(const std::string& description) +auto Arguments::readString(const std::string& description) -> std::string { if (finished()) throw Error("expected " + description + ", got nothing"); @@ -317,7 +317,7 @@ std::string Arguments::readString(const std::string& description) return *m_current++; } -Arguments::Option Arguments::readOption(const std::string& description) +auto Arguments::readOption(const std::string& description) -> Arguments::Option { // clang-format off #define PAIR(string, option) {#string, Option::option} @@ -363,17 +363,17 @@ Arguments::Option Arguments::readOption(const std::string& description) return it->second; } -int Arguments::readInt(const std::string& description) +auto Arguments::readInt(const std::string& description) -> int { return parseInt(readString(description)); } -std::size_t Arguments::readSize(const std::string& description) +auto Arguments::readSize(const std::string& description) -> std::size_t { return parseSize(readString(description)); } -std::vector Arguments::readHex(const std::string& description) +auto Arguments::readHex(const std::string& description) -> std::vector { std::string str = readString(description); @@ -389,7 +389,7 @@ std::vector Arguments::readHex(const std::string& description) return data; } -std::uint32_t Arguments::readKey(const std::string& description) +auto Arguments::readKey(const std::string& description) -> std::uint32_t { std::string str = readString(description); @@ -401,7 +401,7 @@ std::uint32_t Arguments::readKey(const std::string& description) return static_cast(std::stoul(str, nullptr, 16)); } -std::vector Arguments::readCharset() +auto Arguments::readCharset() -> std::vector { const std::bitset<256> lowercase = charRange('a', 'z'); const std::bitset<256> uppercase = charRange('A', 'Z'); diff --git a/src/Attack.cpp b/src/Attack.cpp index 31614b7..d626115 100644 --- a/src/Attack.cpp +++ b/src/Attack.cpp @@ -177,8 +177,8 @@ void Attack::testXlist() progress.state = Progress::State::EarlyExit; } -std::vector attack(const Data& data, const std::vector& zi_2_32_vector, int& start, - std::size_t index, int jobs, const bool exhaustive, Progress& progress) +auto attack(const Data& data, const std::vector& zi_2_32_vector, int& start, std::size_t index, int jobs, + const bool exhaustive, Progress& progress) -> std::vector { const std::uint32_t* candidates = zi_2_32_vector.data(); const auto size = static_cast(zi_2_32_vector.size()); diff --git a/src/Data.cpp b/src/Data.cpp index fe4c2c2..acfd4ca 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -11,12 +11,12 @@ namespace struct Range { - std::size_t size() const + auto size() const -> std::size_t { return std::distance(begin, end); } - bool operator<(const Range& other) const + auto operator<(const Range& other) const -> bool { return size() < other.size(); } diff --git a/src/Zip.cpp b/src/Zip.cpp index c0ec6b8..7772589 100644 --- a/src/Zip.cpp +++ b/src/Zip.cpp @@ -11,7 +11,7 @@ namespace { template -std::istream& read(std::istream& is, T& x) +auto read(std::istream& is, T& x) -> std::istream& { static_assert(N <= sizeof(T), "read requires output type to have at least N bytes"); @@ -23,14 +23,14 @@ std::istream& read(std::istream& is, T& x) return is; } -std::istream& read(std::istream& is, std::string& string, std::size_t length) +auto read(std::istream& is, std::string& string, std::size_t length) -> std::istream& { string.resize(length); return is.read(string.data(), string.size()); } template -std::ostream& write(std::ostream& os, const T& x) +auto write(std::ostream& os, const T& x) -> std::ostream& { static_assert(N <= sizeof(T), "write requires input type to have at least N bytes"); @@ -50,13 +50,13 @@ enum class Signature : std::uint32_t Eocd = 0x06054b50 }; -bool checkSignature(std::istream& is, const Signature& signature) +auto checkSignature(std::istream& is, const Signature& signature) -> bool { std::uint32_t sig; return read(is, sig) && sig == static_cast(signature); } -std::uint64_t findCentralDirectoryOffset(std::istream& is) +auto findCentralDirectoryOffset(std::istream& is) -> std::uint64_t { std::uint64_t centralDirectoryOffset; @@ -137,7 +137,7 @@ Zip::Iterator::Iterator(const Zip& archive) ++(*this); } -Zip::Iterator& Zip::Iterator::operator++() +auto Zip::Iterator::operator++() -> Zip::Iterator& { if (!checkSignature(*m_is, Signature::CentralDirectoryHeader)) return *this = Iterator{}; @@ -251,7 +251,7 @@ Zip::Iterator& Zip::Iterator::operator++() return *this; } -Zip::Iterator Zip::Iterator::operator++(int) +auto Zip::Iterator::operator++(int) -> Zip::Iterator { auto copy = *this; ++(*this); @@ -272,7 +272,7 @@ Zip::Zip(const std::string& filename) { } -Zip::Entry Zip::operator[](const std::string& name) const +auto Zip::operator[](const std::string& name) const -> Zip::Entry { const auto it = std::find_if(begin(), end(), [&name](const Entry& entry) { return entry.name == name; }); @@ -282,7 +282,7 @@ Zip::Entry Zip::operator[](const std::string& name) const return *it; } -Zip::Entry Zip::operator[](std::size_t index) const +auto Zip::operator[](std::size_t index) const -> Zip::Entry { std::size_t nextIndex = 0; const auto it = std::find_if(begin(), end(), [&nextIndex, index](const Entry&) { return nextIndex++ == index; }); @@ -307,7 +307,7 @@ void Zip::checkEncryption(const Entry& entry, Encryption expected) } } -std::istream& Zip::seek(const Entry& entry) const +auto Zip::seek(const Entry& entry) const -> std::istream& { m_is.seekg(entry.offset, std::ios::beg); if (!checkSignature(m_is, Signature::LocalFileHeader)) @@ -324,7 +324,7 @@ std::istream& Zip::seek(const Entry& entry) const return m_is; } -std::vector Zip::load(const Entry& entry, std::size_t count) const +auto Zip::load(const Entry& entry, std::size_t count) const -> std::vector { return loadStream(seek(entry), std::min(entry.packedSize, static_cast(count))); } diff --git a/src/Zreduction.cpp b/src/Zreduction.cpp index 2ea41c6..b4ed926 100644 --- a/src/Zreduction.cpp +++ b/src/Zreduction.cpp @@ -117,12 +117,12 @@ void Zreduction::generate() } } -const std::vector& Zreduction::getCandidates() const +auto Zreduction::getCandidates() const -> const std::vector& { return zi_vector; } -std::size_t Zreduction::getIndex() const +auto Zreduction::getIndex() const -> std::size_t { return index; } diff --git a/src/file.cpp b/src/file.cpp index 8c6944d..840dbf9 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -5,7 +5,7 @@ FileError::FileError(const std::string& description) { } -std::ifstream openInput(const std::string& filename) +auto openInput(const std::string& filename) -> std::ifstream { if (std::ifstream is = std::ifstream(filename, std::ios::binary)) return is; @@ -13,7 +13,7 @@ std::ifstream openInput(const std::string& filename) throw FileError("could not open input file " + filename); } -std::vector loadStream(std::istream& is, std::size_t size) +auto loadStream(std::istream& is, std::size_t size) -> std::vector { std::vector content; std::istreambuf_iterator it(is); @@ -23,13 +23,13 @@ std::vector loadStream(std::istream& is, std::size_t size) return content; } -std::vector loadFile(const std::string& filename, std::size_t size) +auto loadFile(const std::string& filename, std::size_t size) -> std::vector { std::ifstream is = openInput(filename); return loadStream(is, size); } -std::ofstream openOutput(const std::string& filename) +auto openOutput(const std::string& filename) -> std::ofstream { if (std::ofstream os = std::ofstream(filename, std::ios::binary)) return os; diff --git a/src/log.cpp b/src/log.cpp index f7a8e21..54037ff 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -5,13 +5,13 @@ #include #include -std::ostream& put_time(std::ostream& os) +auto put_time(std::ostream& os) -> std::ostream& { const std::time_t t = std::time(nullptr); return os << std::put_time(std::localtime(&t), "%T"); } -std::ostream& operator<<(std::ostream& os, const Keys& keys) +auto operator<<(std::ostream& os, const Keys& keys) -> std::ostream& { const auto flagsBefore = os.setf(std::ios::hex, std::ios::basefield); const auto fillBefore = os.fill('0'); diff --git a/src/main.cpp b/src/main.cpp index c160116..474d564 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,7 +102,7 @@ void decipher(std::istream& is, std::size_t size, std::size_t discard, std::ostr } // namespace -int main(int argc, const char* argv[]) +auto main(int argc, const char* argv[]) -> int try { // enable virtual terminal support on Windows, no-op on other platforms @@ -359,7 +359,7 @@ catch (const BaseError& e) namespace { -std::string getEncryptionDescription(Zip::Encryption encryption) +auto getEncryptionDescription(Zip::Encryption encryption) -> std::string { switch (encryption) { @@ -375,7 +375,7 @@ std::string getEncryptionDescription(Zip::Encryption encryption) return ""; } -std::string getCompressionDescription(Zip::Compression compression) +auto getCompressionDescription(Zip::Compression compression) -> std::string { switch (compression) { diff --git a/src/password.cpp b/src/password.cpp index 4be65e1..96380d1 100644 --- a/src/password.cpp +++ b/src/password.cpp @@ -386,9 +386,9 @@ void recoverPasswordRecursive(Recovery& worker, int jobs, const Keys& initial, c } // namespace -std::vector recoverPassword(const Keys& keys, const std::vector& charset, - std::size_t minLength, std::size_t maxLength, std::string& start, int jobs, - bool exhaustive, Progress& progress) +auto recoverPassword(const Keys& keys, const std::vector& charset, std::size_t minLength, + std::size_t maxLength, std::string& start, int jobs, bool exhaustive, Progress& progress) + -> std::vector { std::vector solutions; std::mutex solutionsMutex;