Loading include/utils.h +8 −12 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ #include <unordered_map> #include <iomanip> inline float percentage(const float& num, const float& den){ return 100 * num / den; } template<typename K, typename V> using UnorderedMapIterator = typename std::unordered_map<K, V>::const_iterator; Loading @@ -26,8 +30,6 @@ using UnorderedMapIterator = typename std::unordered_map<K, V>::const_iterator; template<typename K, typename V> using MapIterator = typename std::map<K, V>::const_iterator; /** * @brief Order an unoredered map whatever the key's type * @param src: unoredered map than needed to be ordered Loading @@ -43,8 +45,6 @@ std::multimap<uint64_t, A> flip_map(const std::unordered_map<A, uint64_t> & src) return dst; } /** * @brief Print a line of statistics * @param res: value of this statistic Loading @@ -55,12 +55,11 @@ std::multimap<uint64_t, A> flip_map(const std::unordered_map<A, uint64_t> & src) */ template<typename Type> void readResult(const uint64_t & res, const Type& carac, int & count, const uint64_t & total_counter, const int & hiderare) { float percentage; std::ostringstream ss; percentage = (float) (100*res) / total_counter; float perc = percentage(res, total_counter); if (percentage >= hiderare) { ss << percentage; if (perc >= hiderare) { ss << perc; std::string value(ss.str()); value = value.substr(0,5); Loading @@ -72,7 +71,6 @@ void readResult(const uint64_t & res, const Type& carac, int & count, const uint } } /** * @brief Print an unordered map * @param stats: map to show Loading @@ -99,13 +97,11 @@ void showMap(const std::unordered_map<Type, uint64_t> & stats, const int & top, } } /** * @brief Calculate the number of line in a file * @param filename: name of the file * @return number of line */ uint64_t nbline_file(const std::string & filename); #endif No newline at end of file src/core/statsgen.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -189,7 +189,7 @@ int Statsgen::generate_stats() { void Statsgen::print_stats() { int count; float perc = (float) 100 * (total_filter / total_counter); float perc = percentage(total_filter, total_counter); cout << "\n\tSelected " << total_filter << " on " << total_counter << " passwords\t(" << perc << " %)" << endl; Loading @@ -202,7 +202,7 @@ void Statsgen::print_stats() { cout << "\tMinimum of lower characters in a password: " << _sr.minLower << endl; cout << "\tMinimum of upper characters in a password: " << _sr.minUpper << endl; float perce = (float) 100 * (_sr.nbSecurePassword / total_counter); float perce = percentage(_sr.nbSecurePassword, total_counter); cout << "\n\t\t--> " << _sr.nbSecurePassword << " passwords\t(" << perce << " %) respect the security rules\n" << endl; Loading Loading
include/utils.h +8 −12 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ #include <unordered_map> #include <iomanip> inline float percentage(const float& num, const float& den){ return 100 * num / den; } template<typename K, typename V> using UnorderedMapIterator = typename std::unordered_map<K, V>::const_iterator; Loading @@ -26,8 +30,6 @@ using UnorderedMapIterator = typename std::unordered_map<K, V>::const_iterator; template<typename K, typename V> using MapIterator = typename std::map<K, V>::const_iterator; /** * @brief Order an unoredered map whatever the key's type * @param src: unoredered map than needed to be ordered Loading @@ -43,8 +45,6 @@ std::multimap<uint64_t, A> flip_map(const std::unordered_map<A, uint64_t> & src) return dst; } /** * @brief Print a line of statistics * @param res: value of this statistic Loading @@ -55,12 +55,11 @@ std::multimap<uint64_t, A> flip_map(const std::unordered_map<A, uint64_t> & src) */ template<typename Type> void readResult(const uint64_t & res, const Type& carac, int & count, const uint64_t & total_counter, const int & hiderare) { float percentage; std::ostringstream ss; percentage = (float) (100*res) / total_counter; float perc = percentage(res, total_counter); if (percentage >= hiderare) { ss << percentage; if (perc >= hiderare) { ss << perc; std::string value(ss.str()); value = value.substr(0,5); Loading @@ -72,7 +71,6 @@ void readResult(const uint64_t & res, const Type& carac, int & count, const uint } } /** * @brief Print an unordered map * @param stats: map to show Loading @@ -99,13 +97,11 @@ void showMap(const std::unordered_map<Type, uint64_t> & stats, const int & top, } } /** * @brief Calculate the number of line in a file * @param filename: name of the file * @return number of line */ uint64_t nbline_file(const std::string & filename); #endif No newline at end of file
src/core/statsgen.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -189,7 +189,7 @@ int Statsgen::generate_stats() { void Statsgen::print_stats() { int count; float perc = (float) 100 * (total_filter / total_counter); float perc = percentage(total_filter, total_counter); cout << "\n\tSelected " << total_filter << " on " << total_counter << " passwords\t(" << perc << " %)" << endl; Loading @@ -202,7 +202,7 @@ void Statsgen::print_stats() { cout << "\tMinimum of lower characters in a password: " << _sr.minLower << endl; cout << "\tMinimum of upper characters in a password: " << _sr.minUpper << endl; float perce = (float) 100 * (_sr.nbSecurePassword / total_counter); float perce = percentage(_sr.nbSecurePassword, total_counter); cout << "\n\t\t--> " << _sr.nbSecurePassword << " passwords\t(" << perce << " %) respect the security rules\n" << endl; Loading