From 27aad6b738ac81613ce23f32abf1932535e03fbc Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 11 Nov 2025 23:03:58 +0000 Subject: [PATCH] c --- 2015_day_4/Makefile | 5 +++++ 2015_day_4/README.md | 8 +++++++- 2015_day_4/day4.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 2015_day_4/Makefile create mode 100644 2015_day_4/day4.c diff --git a/2015_day_4/Makefile b/2015_day_4/Makefile new file mode 100644 index 0000000..3b238af --- /dev/null +++ b/2015_day_4/Makefile @@ -0,0 +1,5 @@ +compile: + gcc day4.c -Werror=switch -o day4 -lcrypto + +run: + ./day4 \ No newline at end of file diff --git a/2015_day_4/README.md b/2015_day_4/README.md index 83f4cef..edd886e 100644 --- a/2015_day_4/README.md +++ b/2015_day_4/README.md @@ -9,4 +9,10 @@ For example: If your secret key is abcdef, the answer is 609043, because the MD5 hash of abcdef609043 starts with five zeroes (000001dbbfa...), and it is the lowest such number to do so. If your secret key is pqrstuv, the lowest number it combines with to make an MD5 hash starting with five zeroes is 1048970; that is, the MD5 hash of pqrstuv1048970 looks like 000006136ef.... -Your puzzle input is yzbqklnj. \ No newline at end of file +Your puzzle input is yzbqklnj. + + + + +I'm going to use the RFC 1321 library here, as designing an md5 implementation is a bit too much for right now +Correction, I will use the old style openssl/md5.h \ No newline at end of file diff --git a/2015_day_4/day4.c b/2015_day_4/day4.c new file mode 100644 index 0000000..2a092c0 --- /dev/null +++ b/2015_day_4/day4.c @@ -0,0 +1,33 @@ +#include +#include +#include + +int main(){ + printf("\nWEST"); + const char *input_string = "yzbqklnj"; + unsigned char output_digest[MD5_DIGEST_LENGTH]; + unsigned long long int iteration_number = 0; + + //creating empty md5 context + MD5_CTX context; + + zeroes = {0,0,0,0,0} + //comparing first 5 digits of output + while (memcmp(charx, zeros, 5) !=0){ + if(!MD5_Init(&context)){ + fprintf(stderr,"Error MD5init failed"); + return 1; + } + //suffix generation + if(iteration_number !=0){ + suffix = iteration_number +1; + } + suffix = + + + } + +} + + +//input = yzbqklnj \ No newline at end of file