Over the past day i have been creating a password generator that after generating a password, it gives you the option to save the password to a .txt file.
Everything is working except the generating/printing the password in the terminal and in the txt file, after typing the lenght of the password, it generates it but doesn't print it.
Here is my code in case someone is interested in helping me.
/*
Password generator by Yataga
github.com/yataga
twitter.com/yataga7
*/
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <fstream>
using namespace std;
int main() {
ofstream SavePass;
char yn;
const char TrueSelect = 'y';
int SelectLengthInput;
string pwd = "0aAbB1cCdD1eEf2F2gG3hHiIjJk3K45lLmM9n5N6o4OpPqQ76rRsStT78uUvVwW98xXyY0zZ";
string password;
cout << "Welcome to Yataga's random password generator" << endl;
cout << "Type the size of yout random password" << endl;
cin >> SelectLengthInput;
cout << "generating your password....."<<endl;
for(int i = 0; i<SelectLengthInput; i++) {
password[i] = pwd[rand()%72];
}
cout<< "Your Password is: "<<password<<endl;
cout<< "do you want to save this password in a file? (y/n): ";
cin>>yn;
if(yn == TrueSelect)
{
SavePass.open("passwords.txt");
SavePass << password;
SavePass.close();
cout<< "Password saved on password.txt"<<endl;
}
else
{
cout<< "Thanks for using my generator!";
}
return 0;
}
Hope someone can help.
Aucun commentaire:
Enregistrer un commentaire