#include <stdio.h>
#include <string.h>
#include "md5mini.h"

int main(void) {
    char password[99], key[56];
    printf("Enter password: ");
    fflush(stdout);
    fgets(password, 99, stdin);
    password[strcspn(password, "\n")] = 0;

    unsigned k = 1;
    for (;;) {
        sprintf(key, "%.42s%u", password, k);
        unsigned char tmp[16];
        md5mini(tmp, key);
        if ((tmp[0] == 0) && (tmp[1] == 0) && (tmp[2] < 16)) break;
        k++;
    }
    printf("use %u for five zeroes\n", k);

    for (;;) {
        sprintf(key, "%.42s%u", password, k);
        unsigned char tmp[16];
        md5mini(tmp, key);
        if ((tmp[0] == 0) && (tmp[1] == 0) && (tmp[2] == 0)) break;
        k++;
    }
    printf("use %u for six zeroes\n", k);
}
