My program produces a different hash code for each variable, and I don't know why.
char check[] = {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
char pw[5];
string checked_hash;
int n = strlen(check);
for(int i = 0; i<n; i++ ) //First for loop
{
printf("Inside for loop for %d\n", i);
pw[0] = check[i];
checked_hash = crypt(pw, salt);
puts(checked_hash);
if( strcmp(checked_hash, user_hash) == 0)
{
printf("If executed\n");
puts(pw);
break;
}
}
The hash code for 'a' has been - 50xeUgkHFeCN2, 50ljncb0HjhsY, 50hxLlS7rvX2Q, 50Bn.g7wo8tuo and other codes completely random. Where am I going wrong?