Advertisement
Guest User

Untitled

a guest
Sep 9th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. // den exw balei sxolia giati eimai kourasmenos
  2. // ama den katalabaineis tipota psa3e sto internet h asto gia argotera na balw sxolia
  3. // prospa8hse pantws
  4. #include <iostream>
  5. #include <fstream>
  6. #include <time.h>
  7.  
  8. void db(char pass[15],char website[15],char username[15],char* filename,char* dbname);
  9. char generate(char password[15],int length);
  10. void writeFile(char password[15],char website,char* filename,char username);
  11. void showDBcontents(char* dbname);
  12. int menu(int choice);
  13. int main(void)
  14. {
  15. while (1)
  16. {
  17. int choice;
  18. char password[15];
  19. char website;
  20. char username;
  21. char username1[15];
  22. char website1[15];
  23. char password1[15];
  24. menu(choice);
  25. switch(choice)
  26. {
  27. case 1:
  28. generate(password,15);
  29. case 2:
  30. writeFile(password,website,"passwords.txt",username);
  31. case 3:
  32. db(password1[password],website1[website],username1[username],"passwords.txt","C:\DATABASE\database.db");
  33. case default:
  34. return 0;
  35. }
  36. }
  37. return 0;
  38. }
  39. int menu(int choice)
  40. {
  41. cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl;
  42. cout << "********1:Generate a random pass********" << endl;
  43. cout << "*********2:Write results to file*********" << endl;
  44. cout << "******3: Output DataBase contents********" << endl;
  45. cout << "****0: Save contents and exit program****" << endl;
  46. cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl;
  47. cout << "Enter your choice: ";
  48. cin >> choice;
  49. }
  50. char generate(char password[15],int length)
  51. {
  52. srand(time(0));
  53. for (int i=0; i<15; i++)
  54. {
  55. pass[i] = rand()%48+72;
  56. }
  57. return pass;
  58. }
  59. void writeFile(char password,char website,char* filename,char username)
  60. {
  61. ifstream newFile;
  62. newFile.oepn(filename);
  63. newFile << "Website: " << website << endl << "Username: " << username << endl << "Password: " << password << endl << endl;
  64. cout << "Results successfully saved in file: " << *filename << endl;
  65. }
  66. void showDBcontents(char* dbname);
  67. {
  68. string contects;
  69. ifstream myfile (dbname);
  70. if (myfile.is_open())
  71. {
  72. while ( myfile.good() )
  73. {
  74. getline (myfile,contects);
  75. cout << line << endl;
  76. }
  77. myfile.close();
  78. }
  79. else;
  80. {
  81. cout << "Database not accessible right now!Please restart the program!\n";
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement