We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
int md5_file(char * name, char * out) { if (name == NULL || out == NULL) { return -1; }
MD5_CTX ctx; md5_init(&ctx);
struct stat st;
if(-1 == stat(name, &st)) { md5_update(&ctx, name, strlen(name)); } else { FILE * fp = fopen(name, "r+");
if (!fp) { fprintf(stderr, "md5_file: open file(%s) error!\n", name); fclose(fp); return -1; } char buff[1024]; memset(buff, 0, sizeof(buff)); size_t len = 0; while (len = fread(buff, 1, sizeof(buff), fp)) { md5_update(&ctx, &buff, len); } fclose(fp);
}
BYTE digest[MD5_BLOCK_SIZE] = {0}; md5_final(&ctx, digest);
for(int idx = 0; idx < MD5_BLOCK_SIZE; idx += 1) { sprintf(out + (idx * 2), "%02x", digest[idx]); }
return 0; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
int md5_file(char * name, char * out) {
if (name == NULL || out == NULL) {
return -1;
}
MD5_CTX ctx;
md5_init(&ctx);
struct stat st;
if(-1 == stat(name, &st)) {
md5_update(&ctx, name, strlen(name));
}
else {
FILE * fp = fopen(name, "r+");
}
BYTE digest[MD5_BLOCK_SIZE] = {0};
md5_final(&ctx, digest);
for(int idx = 0; idx < MD5_BLOCK_SIZE; idx += 1) {
sprintf(out + (idx * 2), "%02x", digest[idx]);
}
return 0;
}
The text was updated successfully, but these errors were encountered: