Commit bd918040 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

operator<< for SecurityRules

parent d38e7831
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ add_executable(cppack
				src/core/Policy.cpp
				src/core/Statistics.cpp
				src/core/Utils.cpp
				src/core/SecurityRules.cpp
				src/cli/Main.cpp)
target_link_libraries(cppack ${CMAKE_THREAD_LIBS_INIT})

@@ -45,6 +46,7 @@ if(Qt5Core_FOUND)
	    src/core/Policy.cpp
	    src/core/Statistics.cpp
	    src/core/Utils.cpp
	    src/core/SecurityRules.cpp
	    ressources/logos.qrc
	)

@@ -60,5 +62,6 @@ add_executable(cppack-test
				src/core/Policy.cpp
				src/core/Statistics.cpp
				src/core/Utils.cpp
				src/core/SecurityRules.cpp
				src/test/cppack-tests.cpp)
target_link_libraries(cppack-test ${CMAKE_THREAD_LIBS_INIT})
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
#ifndef SECURITY_RULES_H
#define SECURITY_RULES_H

#include <ostream>

struct SecurityRules {
	uint minLength;
@@ -11,5 +12,7 @@ struct SecurityRules {
	bool operator==(const SecurityRules& o) const;
};

std::ostream& operator<<(std::ostream& os, const SecurityRules& sec);


#endif
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include <iomanip>
#include <sstream>

typedef unsigned int uint;

inline float percentage(const float& num, const float& den){
	return 100 * num / den;
}
+2 −2
Original line number Diff line number Diff line
@@ -73,11 +73,11 @@ bool Statistics::operator==(const Statistics& o) const {
std::ostream& operator<<(std::ostream& os, const Statistics& results){
	float perc = percentage(results.total_filter, results.total_counter);

	os << "\n\tSelected " << results.total_filter << " on " << results.total_counter << " passwords\t("
	os << "\nSelected " << results.total_filter << " on " << results.total_counter << " passwords\t("
		<< perc << " %)" << endl;

	perc = percentage(results.nb_secure_passwords, results.total_counter);
	os << "\n\t\t--> " << results.nb_secure_passwords << " passwords\t(" << perce << " %) respect the security rules\n" << endl;
	os << "\n\t\t--> " << results.nb_secure_passwords << " passwords\t(" << perc << " %) respect the security rules\n" << endl;

	os << "\nmin - max\n" << endl;
	os << setw(43) << right << "digit:  "
+1 −8
Original line number Diff line number Diff line
@@ -76,14 +76,7 @@ int Statsgen::generate_stats() {

void Statsgen::print_stats() const {
	int count;

	cout << "\nSecurity rules : " << endl;
	cout << "\tMinimal length of a password: " << settings.sr.minLength << endl;
	cout << "\tMinimum of special characters in a password: " << settings.sr.minSpecial << endl;
	cout << "\tMinimum of digits in a password: " << settings.sr.minDigit << endl;
	cout << "\tMinimum of lower characters in a password: " << settings.sr.minLower << endl;
	cout << "\tMinimum of upper characters in a password: " << settings.sr.minUpper << endl;

	cout << settings.sr << endl;
	cout << results << endl;

	cout << "\nStatistics relative to length: \n" << endl;