I thought this code would iterate over all possible combos from aaaa-ZZZZ; however, it fails to do so. I would just like some insight into why my program may not be functioning properly. Thanks in advance.
#define salt "50"
#define _XOPEN_SOURCE
#include <unistd.h>
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(int argc, string argv[])
{
// alert if 1 or 3 arg given
if (argc != 2)
{
printf("Usage: ./crack k\n");
return 1;
}
// store hashed pass
string hashpass = argv[1];
// create alphabet
char alphabet[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
// create pass
char pass[5] = {0};
//iterate to create guess passes
for (int i = 0; i < 52; i++) {
pass[0] = alphabet[i];
for (int j = 0; j < 52; j++) {
pass[1] = alphabet[j];
for (int k = 0; k < 52; k++) {
pass[2] = alphabet[k];
if (hashpass == crypt( pass, salt)) {
printf("%s\n", pass);
return 0;
}
for (int l = 0; l < 52; l++) {
pass[3] = alphabet[l];
if (hashpass == crypt( pass, salt)) {
printf("%s\n", pass);
return 0;
}
}
}
}
}
printf("%s\n", pass);
printf("Failed :(\n");
return 1;
}