Commit 6241ad09 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

Simplify usage of regex

parent 8f0a4bc1
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -50,8 +50,7 @@ struct Statistics {

	minMax minMaxValue;

	std::regex current_regex;
	bool use_regex = false;
	std::string regex_str;
	bool withcount = false;

	uint limitSimplemask;
+2 −6
Original line number Diff line number Diff line
@@ -43,10 +43,7 @@ public:

	inline void setHiderare(const int& hr) { hiderare = hr; }
	inline void setTop(const int& t) { top = t; }
	inline void setRegex(const std::string& reg) {
		current_regex = reg;
		use_regex = true;
	}
	inline void setRegex(const std::string& reg) { regex_str = reg;	}
	inline void setWithcount(const bool& wc) { withcount = wc; }
	inline void setLimitSimplemask(const int& limit) { limitSimplemask = limit; }
	inline void setLimitAdvancedmask(const int& limit) { limitAdvancedmask = limit; }
@@ -72,8 +69,7 @@ private:
	// Filters
	int hiderare = 0; 				// Hide low statistics
	int top = 10;					// Show only a top of statistics
	std::regex current_regex;		// Regex for the interesting passwords
	bool use_regex = false;			// Know if we use a regex or not
	std::string regex_str;		// Regex for the interesting passwords
	bool withcount = false;			// Know if the database is at the format withcount or not
	int limitSimplemask = 12;		// Limit the size of Simple Mask
	int limitAdvancedmask = 12;		// Limit the size of Advanced Mask
+2 −3
Original line number Diff line number Diff line
@@ -30,8 +30,7 @@ void Statsgen::setSecurityRules(const uint& length, const uint& special, const u

void Statsgen::configureThread(Statistics& td) const {
	td.filename = filename;
	td.current_regex = current_regex;
	td.use_regex = use_regex;
	td.regex_str = regex_str;
	td.withcount = withcount;
	td.limitSimplemask = limitSimplemask;
	td.limitAdvancedmask = limitAdvancedmask;
@@ -214,7 +213,7 @@ pair<uint, uint> Statsgen::get_masks(const string& password, PasswordStats& c) c

void Statsgen::handle_password(const string& password, const uint64_t& nbPasswords, Statistics& stats) const {
	stats.total_counter += nbPasswords;
	if(stats.use_regex && !regex_match(password,stats.current_regex)){
	if(stats.regex_str.size() && !regex_match(password, std::regex(stats.regex_str))){
		return;
	}
	PasswordStats c;