I have a server computing the hash of an image and sending the image and hash to the client. I have the client computing the hash of the image it receives. This is the basic setup:
SERVER
unsigned char sum[MD5_DIGEST_LENGTH];
md5sum(tdata, sum);
w = write(newsockfd,sum,MD5_DIGEST_LENGTH);
CLIENT
unsigned char ssum[MD5_DIGEST_LENGTH];
w = read(sockfd,ssum,MD5_DIGEST_LENGTH);
unsigned char sum[MD5_DIGEST_LENGTH];
md5sum(imgpath, sum);
int j;
for (j = 0; j < MD5_DIGEST_LENGTH; j++)
printf("%02x", ssum[j]);
printf("\n");
printf("CLIENT CHECKSUM: ", sum);
for (j = 0; j < MD5_DIGEST_LENGTH; j++)
printf("%02x", sum[j]);
printf("\n");
The outputs are the exact same, but how do I check their equality with an if statement? If I do:
if (sum == ssum)
it always evaluates as false.