CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*This is a simple C++ program that generates a random password*/
/*I have recently modified this code to ensure atleast one number and one special character is included in the password*/
/*The logic behind random strings is derived from http://www.cplusplus.com/forum/windows/88843/*/
/*Edited and Modified by-Amit Mathew*/
/*Don,t forget to upvote the code if you liked it!,😉*/
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
static const char alphnum[]="0123456789" "!@#$%^&*" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz";
int strLen=sizeof(alphnum)-1;
char GenRand()
{
return alphnum[rand()%strLen];
}
int main()
{
int n,c=0,s=0;
srand(time(0));
cout<<"Enter the length of the password required:";
cin>>n;
cout<<n<<endl;
cout<<"Your Password is:";
N:
char C;
string D;
for(int z=0; z < n; z++)
{
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run