我想计算文件的md5,我需要使用openssl库来制作它,但我不知道如何将此库添加到我的文件中
我从此链接下载openssl https://slproweb.com/download/Win64OpenSSL_Light-1_1_1a.exe 我想在c文件中使用
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/md5.h>
char * calculate_file_md5(const char *filename) {
unsigned char c[MD5_DIGEST_LENGTH];
int i;
MD5_CTX mdContext;
int bytes;
unsigned char data[1024];
char *filemd5 = (char*) malloc(33 *sizeof(char));
FILE *inFile = fopen (filename, "rb");
if (inFile == NULL) {
perror(filename);
return 0;
}
MD5_Init (&mdContext);
while ((bytes = fread (data, 1, 1024, inFile)) != 0)
MD5_Update (&mdContext, data, bytes);
MD5_Final (c,&mdContext);
for(i = 0; i < MD5_DIGEST_LENGTH; i++) {
sprintf(&filemd5[i*2], "%02x", (unsigned int)c[i]);
}
printf("calculated md5:%s ", filemd5);
printf (" %s\n", filename);
fclose (inFile);
return filemd5;
}
但是它给出了这个错误 “ openssl / md5.h:没有这样的文件或目录”