Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  bored
Language: C/C++
Code:
#include <Windows.h>
#include <stdio.h>
#include <time.h>

unsigned __int64 custom_rand(){
     time_t xtime;
     time(&xtime);
     xtime+=clock()+rand();
     
     xtime*=clock()+rand();
     return xtime;
}

char * getpw(int s){
     char * pw ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"$%&/()=?1234567890",*pws=(char*)malloc(s+2);
     for(int i=0;i<s;i++){
          pws[i]=pw[custom_rand()%72];
     }
     return pws;
}

int main(){
     CONSOLE_CURSOR_INFO curix; curix.bVisible=0;curix.dwSize=100;
     SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&curix);

     SetConsoleTitleA("Password Generator");
     int times=0,PW_LENGTH=0,need=0;
     printf("How long do you want the password:");
     scanf("%d",&PW_LENGTH);

     printf("How many passwords do you want to generate:");
     scanf("%d",×);

     CONSOLE_CURSOR_INFO curi; curi.bVisible=0;curi.dwSize=10;
     SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&curi);

     printf("nProcess: [          ] %sbbbbbbbbbbbbb","%");
     char*arrpw;
     arrpw = (char*)malloc(times*(PW_LENGTH+2));
     for(int y=0;y<times;y++){
          char* point1=getpw(PW_LENGTH);
          point1[PW_LENGTH]='r';
          point1[PW_LENGTH+1]='n';
          memcpy(arrpw,point1,PW_LENGTH+2);
          arrpw+=PW_LENGTH+2;
          free(point1);
          if(y!=0&&!(y%(times/10))) printf("xdb");
     }

     arrpw-=times*(PW_LENGTH+2);

     HANDLE hfile=CreateFileA("passwords.txt",GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
     WriteFile(hfile, arrpw, times*(PW_LENGTH+2), (LPDWORD)&need, 0);
     free(arrpw);
     CloseHandle(hfile);

     return -1;
}
          
Comments: