So I am trying to solve the password crack. I managed to create all possible 4 letter words with character from A to z. However the encryption using crypt does not always seem to work. I encrypted halo using salt 50 to make 50Ka7rarwEQ1. and when I try to decrypt this, my program does print 'halo'. However, when using the examples provided by the assignment, the program runs for a while and then prints nothing. Does anyone know what I did wrong here?
Thanks!
#define _XOPEN_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(int argc, string argv[])
{
char array[4];
string salt = "50";
if (argc != 2)
{
printf("Error, no hashed password was given.");
return 1;
}
else
{
for (int i = 64; i < 123; i++)
{
char letteri = i;
if (isalpha(letteri))
{
array[0] = i;
}
for (int j = 64; j < 123; j++)
{
char letterj = j;
if (isalpha(letterj))
{
array[1] = j;
}
for (int k = 64; k < 123; k++)
{
char letterk = k;
if (isalpha(letterk))
{
array[2] = letterk;
}
for (int l = 64; l < 123; l++)
{
char letterl = l;
if (isalpha(letterl))
{
array[3] = letterl;
string result = crypt(array,salt);
if (strcmp(result, argv[1]) == 0)
{
printf("%s\n", array);
}
}
}
}
}
}
return 0;
}
}