I am writing a C++ authentication program for concept review and practice. I want to split the Data at Rest portion of the login credentials from the Data in Motion validity and specific username checks.
It seems std::map is the best way to do so before I add in hash and salting... but VS is refusing my attempts at passing references and elements even after initializing blank constructors and the like.
Below is my code from when I gave up after a week and folded the functions into one .h file... how do I split this into two?
{
//create login Credential Map with prestored values
std::map <string, string>CredentialMap = { {"robert", "password123"},{"wayne","password234"}, {"scott","password345"} };
//ask for User's login
std::cout << "Enter Username" << endl;
std::cin >> username;
std::cout << "Enter Password" << endl;
std::cin >> password;
//check if valid login
if (CredentialMap.find(username) != CredentialMap.end() && CredentialMap.at(username) == password) {
return true;
}
else { return false; };
}