51 lines
1023 B
C
51 lines
1023 B
C
#include <color.h>
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
#include "config.h"
|
|
|
|
void
|
|
genkey(int N)
|
|
{
|
|
int count = 0;
|
|
int randomizer = 0;
|
|
|
|
srand((unsigned int)(time(NULL)));
|
|
|
|
char numbers[] = "1234567890";
|
|
char letter[] = "abcdefghijklmnopqrstuvwxyz";
|
|
char LETTER[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
char symbols[] = "!@#$%^&*?";
|
|
char key[N];
|
|
|
|
randomizer = rand() % 4;
|
|
|
|
for (count = 0; count < N; count++) {
|
|
switch (randomizer) {
|
|
case 1:
|
|
key[count] = numbers[rand() % 10];
|
|
randomizer = rand() % 4;
|
|
printf(COL_BLUE "%c" COL_RESET, key[count]);
|
|
break;
|
|
case 2:
|
|
key[count] = symbols[rand() % 8];
|
|
randomizer = rand() % 4;
|
|
printf(COL_BLUE "%c" COL_RESET, key[count]);
|
|
break;
|
|
case 3:
|
|
key[count] = LETTER[rand() % 26];
|
|
randomizer = rand() % 4;
|
|
printf(COL_BLUE "%c" COL_RESET, key[count]);
|
|
break;
|
|
default:
|
|
key[count] = letter[rand() % 26];
|
|
randomizer = rand() % 4;
|
|
printf(COL_BLUE "%c" COL_RESET, key[count]);
|
|
}
|
|
}
|
|
|
|
printf("\n");
|
|
}
|