#include<openssl/md5.h>
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>
char *md51;
char* md52;
char* temp;
char* getMD5(char* fileName);
int main() {
    md51 = (char *)malloc(sizeof(char)*128);
    md52 = (char *)malloc(sizeof(char)*128);
    temp = (char *)malloc(sizeof(char)*64);
    md51 = getMD5("doc1.txt");
    md52 = getMD5("doc2.txt");
    printf("md51 : %s, md52: %s",md51,md52);
    // outputfile = fopen("text.txt", "a");
    // fprintf(outputfile,"%s\n",var);
    // fclose(outputfile);
    return 0;
}

char *getMD5(char* fileName) {
    FILE *fp,*outputfile;
    char var[100];
    char* cmd =  (char *)malloc(sizeof(char)*100);
    char* temp = (char *)malloc(sizeof(char)*50);
    sprintf(cmd,"openssl dgst -md5 %s",fileName);
    fp = popen(cmd, "r");
    while (fgets(var, sizeof(var), fp) != NULL) 
    {   
        printf("%s",var);
    }
    pclose(fp);
    strtok(var,"=");
    temp = strtok(NULL,"=");
    free(cmd);
    // free(temp);
    return temp;
}