Last active
February 2, 2018 10:38
-
-
Save JellyWX/a6bd80a4b7946df8485a24b2a57541c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <map> | |
int main() | |
{ | |
std::string term = ""; | |
std::map<std::string, bool> missing; | |
bool complete = false; | |
do { | |
complete = true; | |
missing["upper"] = false; | |
missing["lower"] = false; | |
missing["number"] = false; | |
missing["special"] = false; | |
std::cout << "Enter a word: "; | |
std::getline(std::cin, term); | |
if (term.size() < 8){ | |
std::cout << "Your password must be longer than 8 characters" << std::endl; | |
complete = false; | |
continue; | |
} | |
for(char c : term){ | |
if (65 <= int(c) and int(c) <= 90){ | |
missing["upper"] = true; | |
} | |
else if (97 <= int(c) and int(c) <= 122) { | |
missing["lower"] = true; | |
} | |
else if (48 <= int(c) and int(c) <= 57) { | |
missing["number"] = true; | |
} else { | |
missing["special"] = true; | |
} | |
} | |
for (auto& kv : missing) { | |
if (not kv.second) { | |
std::cout << "Your password must contain a " << kv.first << " character!" << std::endl; | |
complete = false; | |
} | |
} | |
} while(not complete); | |
std::cout << "Welcome!" << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment