OS1/pads/keygen.c

40 lines
539 B
C
Raw Permalink Normal View History

2023-12-06 13:00:18 -08:00
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "string.h"
int main(int arg, char** args) {
if(arg < 2) {
printf("Not enough Args\n");
return 1;
}
int num_chars = atoi(args[1]);
char* crypto = malloc(sizeof(char) * (num_chars + 10));
srand(time(NULL));
char* tempstr = malloc(sizeof(char) * 2);
while(num_chars) {
char temp = 'A' + (rand() % 26);
sprintf(tempstr, "%c", temp);
strncat(crypto, tempstr, 1);
num_chars--;
}
printf("%s\n", crypto);
return 0;
}