I've been trying to get my crack code working for days now. It took me a while to even understand the problem but I think I have somewhat of a handle on it now. My code compiles completely fine but when I run ./crack 50fkUxYHbnXGw absolutely nothing happens. I get no errors, no output but also my code doesn't even seem to exit. I am never returned to ~/workspace/pset2/crack/. I also can't get debug50 to work either so I'm at a bit of a loss! Any help would be much appreciated.
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define _XOPEN_SOURCE
#include <unistd.h>
char *crypt(const char *key, const char *salt);
int main(int argc, string argv [])
{
if (argc != 2)
{
printf("Error in command line input.\n");
return 1;
}
char key[5];
char salt[] = "50";
char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
while (strcmp(argv[1], crypt(key, salt)) !=0)
{
for (int i = 0; i < 51; i++)
{ key[0] = letters[i];
for (int j = 0; j < 51; j++)
{
key[1] = letters[j];
for (int k = 0; k < 51; k++)
{
key[2] = letters[k];
for (int l = 0; l < 51; l++)
{
key[3] = letters[l];
}
}
}
}
} printf("%s\n", key);
return 0;
}