Commit 9b94fc37 authored by Virendra's avatar Virendra

feat: The Better Idea

parent 4d8e5555
#ifndef PASSWORDS_H #ifndef PASSWORDS_H
#define PASWSWORDS_H #define PASSWORDS_H
#include<map> #include<map>
#include<string> #include<string>
#include<vector>
using namespace std; using namespace std;
map<string, string> passwords { map<string, int> userids {
{"Tinsmorem","Iltil"}, {"Tinsmorem",0},
{"Ulyglet","Snurgrurg"}, {"Ulyglet",1},
{"Lafibnom","Diamdioc"}, {"Lafibnom",2},
{"Thenbovir","Oudrarrouz"}, {"Thenbovir",3},
{"Gallnip","Haulmi"}, {"Gallnip",4},
{"Froolvess","Holdiz"}, {"Froolvess",5},
{"Smameknuc","Hinnyual"}, {"Smameknuc",6},
{"Smedekmet","Traolbubrorg"}, {"Smedekmet",7},
{"Cebbnec","Khishohi"}, {"Cebbnec",8},
{"Klolyddwac","Maennius"}, {"Klolyddwac",9},
{"Blivylnas","Jolmuulmohr"}, {"Blivylnas",10},
{"Glyhamdas","Drustiel"}, {"Glyhamdas",11},
{"Hillnar","Nanruddiarth"}, {"Hillnar",12},
{"Phieddlu","Zussial"}, {"Phieddlu",13},
{"Fnamdyn","Laszo"}, {"Fnamdyn",14},
{"Fladnivith","Nathentoih"}, {"Fladnivith",15},
{"Phelnyll","Phorughoelle"}, {"Phelnyll",16},
{"Snallbam","Skilzeda"}, {"Snallbam",17},
{"Fensmyl","Vrakniarth"}, {"Fensmyl",18},
{"Pibkecim","Jerpuldo"} {"Pibkecim",19},
}; };
//Return true only if the person is present in the database vector<string> passwords {
bool find_user(string name){ "Iltil",
if(passwords.find(name) != passwords.end()) return true; "Snurgrurg",
else return false; "Diamdioc",
"Oudrarrouz",
"Haulmi",
"Holdiz",
"Hinnyual",
"Traolbubrorg",
"Khishohi",
"Maennius",
"Jolmuulmohr",
"Drustiel",
"Nanruddiarth",
"Zussial",
"Laszo",
"Nathentoih",
"Phorughoelle",
"Skilzeda",
"Vrakniarth",
"Jerpuldo"
};
int find_userid(string name){
if(userids.find(name) != userids.end()) return userids[name];
else return -1;
} }
//Returns the password for a particular person
string get_password(string name){ string get_password(string name){
return passwords[name]; int user_id = -1;
if((user_id = find_userid(name)) < 0) return "";
else return passwords[user_id];
} }
#endif #endif
#include "passwords.h" #include "passwords.h"
bool login(string name, string password) bool login(string name, string password)
{ {
if(find_user(name)) if(find_userid(name) >= 0)
{ {
string s = get_password(name); string s = get_password(name);
if(s==password) if(s==password)
......
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