Loading include/ThreadData.h 0 → 100644 +64 −0 Original line number Diff line number Diff line #ifndef THREAD_DATA_H #define THREAD_DATA_H #include <string> #include <unordered_map> #include <queue> #include <climits> #include <regex> #include "Policy.h" #include "SecurityRules.h" typedef std::unordered_map<std::string, uint64_t> StringOccurrence; typedef std::unordered_map<int, uint64_t> IntOccurrence; /** * @brief minimal number of digits of a password, etc. */ class minMax { public: void updateMinMax(const Policy& pol); uint mindigit = UINT_MAX; uint maxdigit = 0; uint minlower = UINT_MAX; uint maxlower = 0; uint minupper = UINT_MAX; uint maxupper = 0; uint minspecial = UINT_MAX; uint maxspecial = 0; }; class ThreadData { public: ThreadData operator+(const ThreadData& other); ThreadData operator+=(const ThreadData& other) const; int thread_id; std::string filename; uint64_t lineBegin = 0; uint64_t lineEnd = 0; uint64_t total_counter = 0; uint64_t total_filter = 0; IntOccurrence length; StringOccurrence simplemasks; StringOccurrence advancedmasks; StringOccurrence charactersets; std::queue<std::string> password_queue; minMax minMaxValue; std::regex current_regex; bool use_regex = false; bool withcount = false; uint limitSimplemask; uint limitAdvancedmask; SecurityRules sr; bool finished = false; }; #endif // THREAD_DATA_H No newline at end of file src/core/ThreadData.cpp 0 → 100644 +59 −0 Original line number Diff line number Diff line #include "ThreadData.h" #include <iostream> using namespace std; void minMax::updateMinMax(const Policy& pol) { mindigit = std::min(mindigit, pol.digit); maxdigit = std::max(maxdigit, pol.digit); minlower = std::min(minlower, pol.lower); maxlower = std::max(maxlower, pol.lower); minupper = std::min(minupper, pol.upper); maxupper = std::max(maxupper, pol.upper); minspecial = std::min(minspecial, pol.special); maxspecial = std::max(maxspecial, pol.special); } ThreadData ThreadData::operator+=(const ThreadData& other) const{ return ThreadData(*this) + other; } ThreadData ThreadData::operator+(const ThreadData& other){ total_counter += other.total_counter; total_filter += other.total_filter; Policy min, max; min.digit = other.minMaxValue.mindigit; min.lower = other.minMaxValue.minlower; min.upper = other.minMaxValue.minupper; min.special = other.minMaxValue.minspecial; max.digit = other.minMaxValue.maxdigit; max.lower = other.minMaxValue.maxlower; max.upper = other.minMaxValue.maxupper; max.special = other.minMaxValue.maxspecial; sr.nbSecurePassword += other.sr.nbSecurePassword; minMaxValue.updateMinMax(min); minMaxValue.updateMinMax(max); for(std::pair<int, uint64_t> occ: other.length){ length[occ.first] += occ.second; } for(std::pair<std::string, int> occ : other.charactersets){ charactersets[occ.first] += occ.second; } for(std::pair<std::string, int> occ: other.simplemasks){ simplemasks[occ.first] += occ.second; } for(std::pair<std::string, int> occ: other.advancedmasks){ advancedmasks[occ.first] += occ.second; } return *this; } No newline at end of file Loading
include/ThreadData.h 0 → 100644 +64 −0 Original line number Diff line number Diff line #ifndef THREAD_DATA_H #define THREAD_DATA_H #include <string> #include <unordered_map> #include <queue> #include <climits> #include <regex> #include "Policy.h" #include "SecurityRules.h" typedef std::unordered_map<std::string, uint64_t> StringOccurrence; typedef std::unordered_map<int, uint64_t> IntOccurrence; /** * @brief minimal number of digits of a password, etc. */ class minMax { public: void updateMinMax(const Policy& pol); uint mindigit = UINT_MAX; uint maxdigit = 0; uint minlower = UINT_MAX; uint maxlower = 0; uint minupper = UINT_MAX; uint maxupper = 0; uint minspecial = UINT_MAX; uint maxspecial = 0; }; class ThreadData { public: ThreadData operator+(const ThreadData& other); ThreadData operator+=(const ThreadData& other) const; int thread_id; std::string filename; uint64_t lineBegin = 0; uint64_t lineEnd = 0; uint64_t total_counter = 0; uint64_t total_filter = 0; IntOccurrence length; StringOccurrence simplemasks; StringOccurrence advancedmasks; StringOccurrence charactersets; std::queue<std::string> password_queue; minMax minMaxValue; std::regex current_regex; bool use_regex = false; bool withcount = false; uint limitSimplemask; uint limitAdvancedmask; SecurityRules sr; bool finished = false; }; #endif // THREAD_DATA_H No newline at end of file
src/core/ThreadData.cpp 0 → 100644 +59 −0 Original line number Diff line number Diff line #include "ThreadData.h" #include <iostream> using namespace std; void minMax::updateMinMax(const Policy& pol) { mindigit = std::min(mindigit, pol.digit); maxdigit = std::max(maxdigit, pol.digit); minlower = std::min(minlower, pol.lower); maxlower = std::max(maxlower, pol.lower); minupper = std::min(minupper, pol.upper); maxupper = std::max(maxupper, pol.upper); minspecial = std::min(minspecial, pol.special); maxspecial = std::max(maxspecial, pol.special); } ThreadData ThreadData::operator+=(const ThreadData& other) const{ return ThreadData(*this) + other; } ThreadData ThreadData::operator+(const ThreadData& other){ total_counter += other.total_counter; total_filter += other.total_filter; Policy min, max; min.digit = other.minMaxValue.mindigit; min.lower = other.minMaxValue.minlower; min.upper = other.minMaxValue.minupper; min.special = other.minMaxValue.minspecial; max.digit = other.minMaxValue.maxdigit; max.lower = other.minMaxValue.maxlower; max.upper = other.minMaxValue.maxupper; max.special = other.minMaxValue.maxspecial; sr.nbSecurePassword += other.sr.nbSecurePassword; minMaxValue.updateMinMax(min); minMaxValue.updateMinMax(max); for(std::pair<int, uint64_t> occ: other.length){ length[occ.first] += occ.second; } for(std::pair<std::string, int> occ : other.charactersets){ charactersets[occ.first] += occ.second; } for(std::pair<std::string, int> occ: other.simplemasks){ simplemasks[occ.first] += occ.second; } for(std::pair<std::string, int> occ: other.advancedmasks){ advancedmasks[occ.first] += occ.second; } return *this; } No newline at end of file