From dfc8768e52e37af9b518afada44f278e136849e3 Mon Sep 17 00:00:00 2001 From: Kemjika-David <125715181+Kemjika-David@users.noreply.github.com> Date: Wed, 29 Mar 2023 00:46:19 +0100 Subject: [PATCH] Create 101_keygen --- 101_keygen | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 101_keygen diff --git a/101_keygen b/101_keygen new file mode 100644 index 0000000..67b86b3 --- /dev/null +++ b/101_keygen @@ -0,0 +1,29 @@ +#include +#include +#include + +/** + * main - Generates a random valid password for 101-crackme + * + * Return: Always 0 + */ +int main(void) +{ + char password[84]; + int i, sum, diff; + + srand(time(NULL)); + + for (i = 0, sum = 0; sum < 2772 - 122; i++) + { + password[i] = rand() % 94 + 33; + sum += password[i]; + } + + diff = sum - 2772 + 122; + password[i] = diff; + + printf("%s", password); + + return (0); +}