aoc2015/d04/run.c

26 lines
556 B
C
Raw Permalink Normal View History

2023-12-01 12:26:36 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/md5.h>
/**
compile with `tcc -lssl run.c`
run with `./a.out | grep -F ' 000000'`, then CTRL+C
*/
void main(int argc, char **argv) {
unsigned char digest[16];
char string[32];
MD5_CTX context;
for (int i=1;;i++) {
printf("%d ",i);
sprintf(string,"ckczppom%d",i);
MD5_Init(&context);
MD5_Update(&context, string, strlen(string));
MD5_Final(digest, &context);
for(int i = 0; i < 16; ++i) {
printf("%02x", (unsigned int)digest[i]);
}
printf("\n");
}
}