Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // den exw balei sxolia giati eimai kourasmenos
- // ama den katalabaineis tipota psa3e sto internet h asto gia argotera na balw sxolia
- // prospa8hse pantws
- #include <iostream>
- #include <fstream>
- #include <time.h>
- void db(char pass[15],char website[15],char username[15],char* filename,char* dbname);
- char generate(char password[15],int length);
- void writeFile(char password[15],char website,char* filename,char username);
- void showDBcontents(char* dbname);
- int menu(int choice);
- int main(void)
- {
- while (1)
- {
- int choice;
- char password[15];
- char website;
- char username;
- char username1[15];
- char website1[15];
- char password1[15];
- menu(choice);
- switch(choice)
- {
- case 1:
- generate(password,15);
- case 2:
- writeFile(password,website,"passwords.txt",username);
- case 3:
- db(password1[password],website1[website],username1[username],"passwords.txt","C:\DATABASE\database.db");
- case default:
- return 0;
- }
- }
- return 0;
- }
- int menu(int choice)
- {
- cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl;
- cout << "********1:Generate a random pass********" << endl;
- cout << "*********2:Write results to file*********" << endl;
- cout << "******3: Output DataBase contents********" << endl;
- cout << "****0: Save contents and exit program****" << endl;
- cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl;
- cout << "Enter your choice: ";
- cin >> choice;
- }
- char generate(char password[15],int length)
- {
- srand(time(0));
- for (int i=0; i<15; i++)
- {
- pass[i] = rand()%48+72;
- }
- return pass;
- }
- void writeFile(char password,char website,char* filename,char username)
- {
- ifstream newFile;
- newFile.oepn(filename);
- newFile << "Website: " << website << endl << "Username: " << username << endl << "Password: " << password << endl << endl;
- cout << "Results successfully saved in file: " << *filename << endl;
- }
- void showDBcontents(char* dbname);
- {
- string contects;
- ifstream myfile (dbname);
- if (myfile.is_open())
- {
- while ( myfile.good() )
- {
- getline (myfile,contects);
- cout << line << endl;
- }
- myfile.close();
- }
- else;
- {
- cout << "Database not accessible right now!Please restart the program!\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement