#include #include #include #include #include //using namespace std; int main() { // Λίστα με passwords για έλεγχο std::vector passwords = { "Pass123!", // Valid "weak", // Invalid (μικρό μέγεθος) "OnlyLetters", // Invalid (λείπουν αριθμοί/σύμβολα) "NoSpecial12", // Invalid (λείπει ειδικός χαρακτήρας) "Valid_Pass_2026", // Valid "12345678", // Invalid (λείπουν γράμματα) "Ab1!" // Invalid (πολύ μικρό) }; // Λάμδα για τον έλεγχο εγκυρότητας auto isValid = [specialChars = std::string("!@#$%^&*()-_=+[]{}|;:,.<>?/")](const std::string& p) -> bool { if (p.length() < 8) return false; bool hasUpper = false, hasLower = false, hasDigit = false, hasSpecial = false; for (char c : p) { if (std::isupper(c)) hasUpper = true; else if (std::islower(c)) hasLower = true; else if (std::isdigit(c)) hasDigit = true; else if (specialChars.find(c) != std::string::npos) hasSpecial = true; } return hasUpper && hasLower && hasDigit && hasSpecial; }; std::cout << "------- Checking Passwords -----------" << std::endl; std::cout << "Position | Masked Password | Status" << std::endl; std::cout << "--------------------------------------" << std::endl; for (size_t i = 0; i < passwords.size(); ++i) { bool valid = isValid(passwords[i]); // Εκτύπωση θέσης (i + 1) std::cout << "[" << i + 1 << "] "; // Εκτύπωση αστερίσκων αντί για το password std::string masked(passwords[i].length(), '*'); std::cout << masked; // Ευθυγράμμιση εξόδου (padding) int padding = 15 - (int)passwords[i].length(); for(int j=0; j < (padding > 0 ? padding : 1); ++j) std::cout << " "; std::cout << "| " << (valid ? "VALID" : "INVALID") << std::endl; } return 0; }