Friday, July 30, 2010

PASSWORD DEVELOPER

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include<conio.h>
int n;
char *rand_str(char *dst, int size)
{
   static const char text[] = "abcdefghijklmnopqrstuvwxyz"
                  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                  "1234567890"
                  "`~!@#$%^&*()_+,./;':?><[]{}|\"";
   int i,len=rand()%(size-1);
   for ( i = 0; i < n ; ++i )
   {
      dst[i] = text[rand() % (sizeof text - 1)];
   }
   dst[i] = '\0';
   return dst;
}

int main (void)
{
   clrscr();
   printf("\n\n\n\t\t\tPASSWORD DEVELOPER\n\n\n");
   printf("  enter the length of password required\t");
   scanf("%d",&n);
   char mytext[10];
   srand(time(0));
   gotoxy(9,10);
   printf("a C programmed random password is ");
   puts(rand_str(mytext, sizeof mytext));
   printf("\n\thit any key to exit......");
   getch();
   return 0;
}

No comments:

Post a Comment

FOLLOWERS