Loading .gitignore +3 −2 Changes for .gitignore: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Utils/convert Utils/createNewDB Adaptation/main Adaptation/bin AdaprationParallel/main AdaprationParallel/bin AdaptationParallel/main AdaptationParallel/bin Pack/ No newline at end of file Adaptation/include/statsgen.h −18 Changes for Adaptation/include/statsgen.h: 0 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -72,22 +72,4 @@ private: int maxupper = -1; int minspecial = -1; int maxspecial = -1; // Time float timeLetterTotal = 0; int nbLetterCalc = 0; float timeCharsetTotal = 0; int nbCharsetCalc = 0; float timeMinMaxTotal = 0; int nbMinMaxCalc = 0; float timeGetlineTotal = 0; int nbGetlineCalc = 0; float timeTotal = 0; }; No newline at end of file Adaptation/include/utils.h +1 Changes for Adaptation/include/utils.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line #include <map> #include <iostream> #include <unordered_map> using namespace std; Loading AdaptationParallel/include/ThreadPool.h +98 Changes for AdaptationParallel/include/ThreadPool.h: 98 added lines, 0 removed lines. Original line number Diff line number Diff line #ifndef THREAD_POOL_H #define THREAD_POOL_H #include <vector> #include <queue> #include <memory> #include <thread> #include <mutex> #include <condition_variable> #include <future> #include <functional> #include <stdexcept> class ThreadPool { public: ThreadPool(size_t); template<class F, class... Args> auto enqueue(F&& f, Args&&... args) -> std::future<typename std::result_of<F(Args...)>::type>; ~ThreadPool(); private: // need to keep track of threads so we can join them std::vector< std::thread > workers; // the task queue std::queue< std::function<void()> > tasks; // synchronization std::mutex queue_mutex; std::condition_variable condition; bool stop; }; // the constructor just launches some amount of workers inline ThreadPool::ThreadPool(size_t threads) : stop(false) { for(size_t i = 0;i<threads;++i) workers.emplace_back( [this] { for(;;) { std::function<void()> task; { std::unique_lock<std::mutex> lock(this->queue_mutex); this->condition.wait(lock, [this]{ return this->stop || !this->tasks.empty(); }); if(this->stop && this->tasks.empty()) return; task = std::move(this->tasks.front()); this->tasks.pop(); } task(); } } ); } // add new work item to the pool template<class F, class... Args> auto ThreadPool::enqueue(F&& f, Args&&... args) -> std::future<typename std::result_of<F(Args...)>::type> { using return_type = typename std::result_of<F(Args...)>::type; auto task = std::make_shared< std::packaged_task<return_type()> >( std::bind(std::forward<F>(f), std::forward<Args>(args)...) ); std::future<return_type> res = task->get_future(); { std::unique_lock<std::mutex> lock(queue_mutex); // don't allow enqueueing after stopping the pool if(stop) throw std::runtime_error("enqueue on stopped ThreadPool"); tasks.emplace([task](){ (*task)(); }); } condition.notify_one(); return res; } // the destructor joins all threads inline ThreadPool::~ThreadPool() { { std::unique_lock<std::mutex> lock(queue_mutex); stop = true; } condition.notify_all(); for(std::thread &worker: workers) worker.join(); } #endif AdaptationParallel/include/statsgen.h +86 Changes for AdaptationParallel/include/statsgen.h: 86 added lines, 0 removed lines. Original line number Diff line number Diff line #include <string> #include <unordered_map> #include <iostream> #include <regex> struct Policy{ int digit = 0; int lower = 0; int upper = 0; int special = 0; }; struct Conteneur{ int pass_length = 0; std::wstring characterset = L""; std::wstring advancedmask_string = L""; std::wstring simplemask_string = L""; Policy pol; }; class Statsgen { public: Statsgen() {}; void showHelp(); void setHiderare(int); void setTop(int); void setRegex(std::string); void setWithcount(bool); void setLimitSimplemask(int); void setLimitAdvancedmask(int); int generate_stats(const std::string &); void print_stats(); private: // functions void updateMinMax(const Policy &); // Filters int hiderare = 0; int top = -1; std::wregex current_regex; bool use_regex = false; bool withcount = false; int limitSimplemask = 0; int limitAdvancedmask = 0; // dico std::unordered_map<int, int> stats_length; std::unordered_map<std::wstring, int> stats_simplemasks; std::unordered_map<std::wstring, int> stats_advancedmasks; std::unordered_map<std::wstring, int> stats_charactersets; double total_counter = 0; double total_filter = 0; // Minimum password complexity counters int mindigit = -1; int maxdigit = -1; int minlower = -1; int maxlower = -1; int minupper = -1; int maxupper = -1; int minspecial = -1; int maxspecial = -1; }; Conteneur analyze_password(const std::wstring&); void analyse_letter(const char &, char &, std::wstring &, std::wstring &, Policy &, int &, int &); void analyse_charset(std::wstring &, const Policy &); No newline at end of file Loading
.gitignore +3 −2 Changes for .gitignore: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Utils/convert Utils/createNewDB Adaptation/main Adaptation/bin AdaprationParallel/main AdaprationParallel/bin AdaptationParallel/main AdaptationParallel/bin Pack/ No newline at end of file
Adaptation/include/statsgen.h −18 Changes for Adaptation/include/statsgen.h: 0 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -72,22 +72,4 @@ private: int maxupper = -1; int minspecial = -1; int maxspecial = -1; // Time float timeLetterTotal = 0; int nbLetterCalc = 0; float timeCharsetTotal = 0; int nbCharsetCalc = 0; float timeMinMaxTotal = 0; int nbMinMaxCalc = 0; float timeGetlineTotal = 0; int nbGetlineCalc = 0; float timeTotal = 0; }; No newline at end of file
Adaptation/include/utils.h +1 Changes for Adaptation/include/utils.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line #include <map> #include <iostream> #include <unordered_map> using namespace std; Loading
AdaptationParallel/include/ThreadPool.h +98 Changes for AdaptationParallel/include/ThreadPool.h: 98 added lines, 0 removed lines. Original line number Diff line number Diff line #ifndef THREAD_POOL_H #define THREAD_POOL_H #include <vector> #include <queue> #include <memory> #include <thread> #include <mutex> #include <condition_variable> #include <future> #include <functional> #include <stdexcept> class ThreadPool { public: ThreadPool(size_t); template<class F, class... Args> auto enqueue(F&& f, Args&&... args) -> std::future<typename std::result_of<F(Args...)>::type>; ~ThreadPool(); private: // need to keep track of threads so we can join them std::vector< std::thread > workers; // the task queue std::queue< std::function<void()> > tasks; // synchronization std::mutex queue_mutex; std::condition_variable condition; bool stop; }; // the constructor just launches some amount of workers inline ThreadPool::ThreadPool(size_t threads) : stop(false) { for(size_t i = 0;i<threads;++i) workers.emplace_back( [this] { for(;;) { std::function<void()> task; { std::unique_lock<std::mutex> lock(this->queue_mutex); this->condition.wait(lock, [this]{ return this->stop || !this->tasks.empty(); }); if(this->stop && this->tasks.empty()) return; task = std::move(this->tasks.front()); this->tasks.pop(); } task(); } } ); } // add new work item to the pool template<class F, class... Args> auto ThreadPool::enqueue(F&& f, Args&&... args) -> std::future<typename std::result_of<F(Args...)>::type> { using return_type = typename std::result_of<F(Args...)>::type; auto task = std::make_shared< std::packaged_task<return_type()> >( std::bind(std::forward<F>(f), std::forward<Args>(args)...) ); std::future<return_type> res = task->get_future(); { std::unique_lock<std::mutex> lock(queue_mutex); // don't allow enqueueing after stopping the pool if(stop) throw std::runtime_error("enqueue on stopped ThreadPool"); tasks.emplace([task](){ (*task)(); }); } condition.notify_one(); return res; } // the destructor joins all threads inline ThreadPool::~ThreadPool() { { std::unique_lock<std::mutex> lock(queue_mutex); stop = true; } condition.notify_all(); for(std::thread &worker: workers) worker.join(); } #endif
AdaptationParallel/include/statsgen.h +86 Changes for AdaptationParallel/include/statsgen.h: 86 added lines, 0 removed lines. Original line number Diff line number Diff line #include <string> #include <unordered_map> #include <iostream> #include <regex> struct Policy{ int digit = 0; int lower = 0; int upper = 0; int special = 0; }; struct Conteneur{ int pass_length = 0; std::wstring characterset = L""; std::wstring advancedmask_string = L""; std::wstring simplemask_string = L""; Policy pol; }; class Statsgen { public: Statsgen() {}; void showHelp(); void setHiderare(int); void setTop(int); void setRegex(std::string); void setWithcount(bool); void setLimitSimplemask(int); void setLimitAdvancedmask(int); int generate_stats(const std::string &); void print_stats(); private: // functions void updateMinMax(const Policy &); // Filters int hiderare = 0; int top = -1; std::wregex current_regex; bool use_regex = false; bool withcount = false; int limitSimplemask = 0; int limitAdvancedmask = 0; // dico std::unordered_map<int, int> stats_length; std::unordered_map<std::wstring, int> stats_simplemasks; std::unordered_map<std::wstring, int> stats_advancedmasks; std::unordered_map<std::wstring, int> stats_charactersets; double total_counter = 0; double total_filter = 0; // Minimum password complexity counters int mindigit = -1; int maxdigit = -1; int minlower = -1; int maxlower = -1; int minupper = -1; int maxupper = -1; int minspecial = -1; int maxspecial = -1; }; Conteneur analyze_password(const std::wstring&); void analyse_letter(const char &, char &, std::wstring &, std::wstring &, Policy &, int &, int &); void analyse_charset(std::wstring &, const Policy &); No newline at end of file