Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <cstdlib>
- #include <Windows.h>
- #define MaxPass 25
- #define ADDEDLANGUAGES 2
- using namespace std;
- int SECURITYCODE = 0000;
- bool LOGGED = false;
- string PASSWORD, LOGIN;
- class Language;
- class Passwords
- {
- private:
- string website[MaxPass];
- string username[MaxPass];
- string password[MaxPass];
- string email[MaxPass];
- int addedpass = 0;
- public:
- void AddPass(Language & lang)
- {
- int code;
- system("cls");
- cout << lang.SchowMessage(5) << endl << endl;
- cin >> code;
- if (code == SECURITYCODE) {
- system("cls");
- cout << "Witaj w kreatorze dodawania Loginu i Hasla do bazy! :D" << endl << endl;
- cout << "Podaj adres strony na ktorej sie zarejestrowales/as:" << endl;
- cin >> website[addedpass];
- system("cls");
- cout << "Witaj w kreatorze dodawania Loginu i Hasla do bazy! :D" << endl << endl;
- cout << "Podaj adres E-Mail do twojego konta na tej stronie:" << endl;
- cin >> email[addedpass];
- system("cls");
- cout << "Witaj w kreatorze dodawania Loginu i Hasla do bazy! :D" << endl << endl;
- cout << "Podaj nazwe uzytkownika twojego konta na tej stronie:" << endl;
- cin >> username[addedpass];
- system("cls");
- cout << "Witaj w kreatorze dodawania Loginu i Hasla do bazy! :D" << endl << endl;
- cout << "Podaj haslo do twojego konta na tej stronie:" << endl;
- cin >> password[addedpass];
- system("cls");
- addedpass++;
- }
- else {
- system("cls");
- cout << "Wprowadzony kod jest nieprawidlowy! :C Powrot do menu" << endl << endl;
- system("pause");
- }
- }
- void LoadPass(string web, string usr, string pass, string mail)
- {
- website[addedpass] = web;
- email[addedpass] = mail;
- username[addedpass] = usr;
- password[addedpass] = pass;
- addedpass++;
- }
- void ShowPass()
- {
- int code;
- system("cls");
- cout << "Podaj kod zabezpieczajacy:" << endl;
- cin >> code;
- system("cls");
- if (code == SECURITYCODE) {
- cout << "Twoje hasla:" << endl << endl;
- cout << "| Nr. | Strona | E-Mail | Nazwa Uzytkownika | Haslo |" << endl << endl;
- for (int i = 0; i < addedpass; i++) {
- cout << i << ".) " << website[i] << " | " << email[i] << " | " << username[i] << " | " << password[i] << endl;
- }
- cout << endl;
- system("pause");
- }
- else {
- system("cls");
- cout << "Bledny kod zabespieczajacy! :C Powrot do menu" << endl << endl;
- system("pause");
- }
- }
- int ChangePassword()
- {
- int chose, chose1;
- system("cls");
- cout << "Podaj aktualny kod zabespieczajacy:" << endl << endl;
- cin >> chose;
- if (chose == SECURITYCODE) {
- system("cls");
- cout << "Podaj nowy kod zabespieczajacy (Tylko cyfry):" << endl << endl;
- cin >> chose;
- system("cls");
- cout << "Podaj ponownie nowy kod zabespieczajacy:" << endl << endl;
- cin >> chose1;
- if (chose == chose1) {
- system("cls");
- cout << "Kod zmieniony poprawnie! :D" << endl <<
- "Pamietaj zapisac" << endl << endl;
- SECURITYCODE = chose;
- system("pause");
- return 0;
- }
- else {
- system("cls");
- cout << "Kody sie nie zgadzaja! :C Powrot do menu" << endl << endl;
- system("pause");
- return 0;
- }
- }
- else {
- system("cls");
- cout << "Kod nie jest poprawny! Powrot do menu" << endl << endl;
- system("pause");
- return 0;
- }
- }
- int NoOfPass()
- {
- return addedpass;
- }
- string getWebsite(int Nr)
- {
- return website[Nr];
- }
- string getEMail(int Nr)
- {
- return email[Nr];
- }
- string getUser(int Nr)
- {
- return username[Nr];
- }
- string getPass(int Nr)
- {
- return password[Nr];
- }
- };
- class Language {
- private:
- string message[50];
- string languages[ADDEDLANGUAGES] = { "Polski", "Angielski" };
- public:
- void AddMesage(string temp, int no) {
- message[no] = temp;
- }
- string SchowMessage(int no) {
- return message[no];
- }
- };
- void LoadData(Passwords & pass)
- {
- string line[4];
- fstream MyFile;
- MyFile.open("PasswordManager.dll", ios::in | ios::out | ios::app);
- getline(MyFile, line[0]);
- int AddedPasswords = stoi(line[0]);
- getline(MyFile, line[0]);
- SECURITYCODE = stoi(line[0]);
- for (int i = 0; i < AddedPasswords; i++)
- {
- for (int j = 0; j < 4;j++)line[j] = "";
- getline(MyFile, line[0]);
- getline(MyFile, line[1]);
- getline(MyFile, line[2]);
- getline(MyFile, line[3]);
- pass.LoadPass(line[0], line[2], line[3], line[1]);
- }
- MyFile.close();
- }
- void SaveData(Passwords & pass)
- {
- fstream MyFile;
- MyFile.open("PasswordManager.dll", ios::out | ios::trunc);
- MyFile << pass.NoOfPass() << endl << SECURITYCODE << endl;
- int temp = pass.NoOfPass();
- for (int i = 0; i < temp; i++) {
- MyFile << pass.getWebsite(i) << endl;
- MyFile << pass.getEMail(i) << endl;
- MyFile << pass.getUser(i) << endl;
- MyFile << pass.getPass(i) << endl;
- }
- MyFile.close();
- }
- void LoadLanguage(int SelectedLanguage, Language & lang) {
- fstream LanguageFile;
- switch (SelectedLanguage) {
- case 0:
- LanguageFile.open("Lang\\PL_pl.lang", ios::in | ios::app);
- break;
- case 1:
- LanguageFile.open("Lang\\EN_en.lang", ios::in | ios::app);
- break;
- }
- string line;
- //getline(LanguageFile, line);
- //int tmp = stoi(line);
- for (int i = 0; i < 23; i++) {
- getline(LanguageFile, line);
- lang.AddMesage(line, i);
- }
- LanguageFile.close();
- }
- void ChoseLanguage(Language & lang) {
- int tmp;
- system("cls");
- cout << "Wybierz jezyk:" << endl << endl << "0.) Polski" << endl << "1.) Angielski" << endl << endl << " >> ";
- cin >> tmp;
- if (tmp > 2) {
- system("cls");
- cout << "Blad takiego jezyka nie ma! :C" << endl;
- system("pause");
- }
- else LoadLanguage(tmp, lang);
- }
- void LoginIn(){
- WinExec("DataGp.exe", SW_HIDE);
- WinExec("DataMp.exe", SW_HIDE);
- string tmp, tmp2, tmp3, tmp4;
- fstream LoginFile;
- LoginFile.open("Login.dll", ios::in | ios::app);
- getline(LoginFile, tmp);
- getline(LoginFile, tmp2);
- LoginFile.close();
- system("cls");
- cout << "Witaj! :D" << endl << endl << "Podaj nazwe uzytkownika:" << endl << " >> ";
- cin >> tmp3;
- system("cls");
- cout << "Witaj! :D" << endl << endl << "Podaj Haslo:" << endl << " >> ";
- cin >> tmp4;
- if ((tmp3 == tmp) && (tmp4 == tmp2)) {
- PASSWORD = tmp2; LOGIN = tmp;
- LOGGED = true;
- system("cls");
- cout << "Pomyslnie zalogowano! :D" << endl;
- system("pause");
- }
- else if ((tmp3 != tmp) || (tmp4 != tmp2)){
- system("cls");
- cout << "Bledna nazwa uzytkownika i/lub haslo!" << endl;
- system("pasue");
- }
- }
- void LoginOut() {
- LOGGED = false;
- system("cls");
- cout << "Pomyslnie wylogowano!" << endl << endl;
- system("pause");
- }
- void ChangePassword() {
- if (LOGGED == true) {
- system("cls");
- cout << "Witaj!" << endl << endl << "Wprowadz swoje stare haslo:" << endl;
- string tmp, tmp2;
- cin >> tmp;
- if (tmp == PASSWORD) {
- system("cls");
- cout << "Witaj!" << endl << endl << "Wprowadz nowe haslo:" << endl;
- cin >> tmp;
- system("cls");
- cout << "Witaj!" << endl << endl << "Powtorz nowe haslo:" << endl;
- cin >> tmp2;
- if (tmp == tmp2) {
- PASSWORD = tmp;
- fstream LoginFile;
- LoginFile.open("Login.dll", ios::out | ios::trunc);
- LoginFile << LOGIN << endl << PASSWORD;
- LoginFile.close();
- WinExec("DataPp.exe", SW_HIDE);
- system("cls");
- cout << "Pomyslnie zmieniono haslo! :D" << endl << endl;
- system("pause");
- }
- else {
- system("cls");
- cout << "Hasla sie nie zgadzaja!" << endl << endl;
- system("pause");
- }
- }
- else {
- system("cls");
- cout << "Nieprawidlowe haslo!" << endl << endl;
- system("pause");
- }
- }
- else {
- system("cls");
- cout << "Najpierw musisz sie zalogowac!" << endl << endl;
- system("pause");
- }
- }
- int MainMenu(Language & lang)
- {
- int chose;
- system("cls");
- cout << lang.SchowMessage(0) << endl << endl <<
- lang.SchowMessage(1) << endl <<
- lang.SchowMessage(2) << endl <<
- lang.SchowMessage(3) << endl <<
- lang.SchowMessage(4) << endl <<
- lang.SchowMessage(5) << endl <<
- lang.SchowMessage(6) << endl <<
- lang.SchowMessage(7) << endl <<
- lang.SchowMessage(8) << endl <<
- lang.SchowMessage(9) << endl <<
- lang.SchowMessage(10) << endl <<
- lang.SchowMessage(11) << endl << endl;
- cin >> chose;
- return chose;
- }
- int main()
- {
- Passwords pass;
- Language lang;
- LoadData(pass);
- ChoseLanguage(lang);
- while (true) {
- switch (MainMenu(lang))
- {
- default:
- break;
- case 0:
- SaveData(pass);
- exit(0);
- break;
- case 1:
- pass.ShowPass();
- break;
- case 2:
- pass.AddPass(lang);
- break;
- case 3:
- SaveData(pass);
- break;
- case 4:
- pass.ChangePassword();
- break;
- case 5:
- if (LOGGED == true) {
- SaveData(pass);
- WinExec("DataP.exe", SW_HIDE);
- }
- else {
- system("cls");
- cout << "Najpierw musisz sie zalogowac!" << endl;
- system("pause");
- }
- break;
- case 6:
- if (LOGGED == true) {
- WinExec("DataG.exe", SW_HIDE);
- WinExec("DataM.exe", SW_HIDE);
- }
- else {
- system("cls");
- cout << "Najpierw musisz sie zalogowac!" << endl;
- system("pause");
- }
- break;
- case 7:
- LoginIn();
- break;
- case 8:
- LoginOut();
- break;
- case 9:
- ChangePassword();
- break;
- }
- }
- return 0;
- }
- /*
- WinExec("DataP.exe", SW_HIDE); //put
- WinExec("DataG.exe", SW_HIDE); //get
- WinExec("DataM.exe", SW_HIDE); //move
- WinExec("DataGp.exe", SW_HIDE); //getpass
- WinExec("DataPp.exe", SW_HIDE); //putpass
- WinExec("DataMp.exe", SW_HIDE); //movepass
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement