From fdeb0b4cb8e8ba837d98414c15c460cf8018b2a6 Mon Sep 17 00:00:00 2001 From: stitchy Date: Wed, 6 Dec 2023 21:00:18 +0000 Subject: [PATCH] complete keygen program --- pads/keygen.c | 39 +++++++++++++++++++++++++++++++++++++++ pads/makefile | 13 +++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 pads/keygen.c create mode 100644 pads/makefile diff --git a/pads/keygen.c b/pads/keygen.c new file mode 100644 index 0000000..9f8c78b --- /dev/null +++ b/pads/keygen.c @@ -0,0 +1,39 @@ +#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; +} diff --git a/pads/makefile b/pads/makefile new file mode 100644 index 0000000..7e7e090 --- /dev/null +++ b/pads/makefile @@ -0,0 +1,13 @@ +CC=gcc --std=gnu99 -g + +all: keygen + echo Everything Made + +keygen: keygen.c + $(CC) keygen.c -o keygen + +run: all + ./$(output) + +clean: + rm -fr *.o vgcore.* $(output)