VB icon

Password Generator

Email
Submitted on: 8/12/2016 7:28:57 PM
By: Ben128  
Level: Beginner
User Rating: By 1 Users
Compatibility: C++ (general), Microsoft Visual C++
Views: 1388
 
     Simple password generator that takes a length as input and prints a random password with uppercase, lowercase and numbers.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Password Generator
// Description:Simple password generator that takes a length as input and prints a random password with uppercase, lowercase and numbers.
// By: Ben128
//**************************************

#include <iostream>
#include <string>
#include <time.h>
using namespace std;
using std::endl;
using std::count;
int rnd = 0;
void PrintRndPass(int Length){
	char *charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	int i = 0;
	//Setup random generator
	srand(time(0));
	while(i < Length){
		rnd = rand() & strlen(charset) - 1;
		//Print out password
		cout << charset[rnd];
		//INC counter
		i++;
	}
	cout << endl;
}
void main()
{
	int len = 0;
	system("title Password Generator");
	cout << "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" << endl;
	cout << "ºRandom Password Generator º" << endl;
	cout << "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" << endl;
	cout << "Enter length of password: ";
	//Read in length
	cin >> len;
	//Print password
	cout << "Password: ";
	PrintRndPass(len);
	//Pause
	system("pause");
}


Other 50 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.