Commit c57125b9 authored by khy724's avatar khy724

feat: The Better Idea

parent 8eca7243
File added
#include<iostream> #include <iostream>
#include"utils.h" #include "utils.h"
#include <string>
using namespace std; using namespace std;
int main() { int main() {
char* nm, pwd; string nm, pwd;
cout<<"Enter your name"<<endl; cout<<"Enter your name"<<endl;
cin>>nm; cin>>nm;
cout<<"Enter your password"<<endl; cout<<"Enter your password"<<endl;
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
#include<map> #include<map>
#include<string> #include<string>
#include<vector>
using namespace std; using namespace std;
map<string, string> passwords { /*map<string, string> passwords {
{"Tinsmorem","Iltil"}, {"Tinsmorem","Iltil"},
{"Ulyglet","Snurgrurg"}, {"Ulyglet","Snurgrurg"},
{"Lafibnom","Diamdioc"}, {"Lafibnom","Diamdioc"},
...@@ -28,16 +29,76 @@ map<string, string> passwords { ...@@ -28,16 +29,76 @@ map<string, string> passwords {
{"Fensmyl","Vrakniarth"}, {"Fensmyl","Vrakniarth"},
{"Pibkecim","Jerpuldo"} {"Pibkecim","Jerpuldo"}
}; };
*/
map<string, int> userids {
{"Tinsmorem",0},
{"Ulyglet",1},
{"Lafibnom",2},
{"Thenbovir",3},
{"Gallnip",4},
{"Froolvess",5},
{"Smameknuc",6},
{"Smedekmet",7},
{"Cebbnec",8},
{"Klolyddwac",9},
{"Blivylnas",10},
{"Glyhamdas",11},
{"Hillnar",12},
{"Phieddlu",13},
{"Fnamdyn",14},
{"Fladnivith",15},
{"Phelnyll",16},
{"Snallbam",17},
{"Fensmyl",18},
{"Pibkecim",19},
};
vector<string> passwords {
"Iltil",
"Snurgrurg",
"Diamdioc",
"Oudrarrouz",
"Haulmi",
"Holdiz",
"Hinnyual",
"Traolbubrorg",
"Khishohi",
"Maennius",
"Jolmuulmohr",
"Drustiel",
"Nanruddiarth",
"Zussial",
"Laszo",
"Nathentoih",
"Phorughoelle",
"Skilzeda",
"Vrakniarth",
"Jerpuldo"
};
//Return true only if the person is present in the database //Return true only if the person is present in the database
bool find_user(string name){ /*bool find_user(string name){
if(passwords.find(name) != passwords.end()) return true; if(passwords.find(name) != passwords.end()) return true;
else return false; else return false;
} }*/
//Returns the password for a particular person //Returns the password for a particular person
string get_password(string name){ /*string get_password(string name){
return passwords[name]; return passwords[name];
}*/
bool find_userid(string name){
if(userids.find(name) != userids.end()) return userids[name];
else return -1;
}
string get_password(string name){
int user_id = -1;
if((user_id = find_userid(name)) < 0) return "";
else return passwords[user_id];
} }
#endif #endif
File added
#include<iostream> #include<iostream>
#include"password.h" #include "passwords.h"
#include<string>
#include<vector>
using namespace std; using namespace std;
map<strings,strings> passwords; //vector<string,string> passwords;
bool login(string name, string password) { bool login(string name, string password) {
if(passwords.find(name) != passwords.end() && passwords[name]==password) return true; if( get_password(name)==password) return true;
else return false; else return false;
} }
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment