Showing posts with label random number. Show all posts
Showing posts with label random number. Show all posts

Friday, 11 August 2017

Code to generate 32 random ascii characters

Hi,

It is a code to generate random 32 ASCII characters, you can modify it according to your need. You can use it for generating Passwords, encrypting passwords and many more things.



[code]
#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace std;

int main (int argc, char *argv[])
{
char st[31];
int temp;
srand(time(0));
for (int c=0;c<32;c++)
{
for(int i=1;i<2;i++)
{
temp=0;
while(temp<32 || temp>126)
   temp = rand()%126;
st[c] = temp;

}
}
cout<<st;
return 0;
}
[/code]