ive been looking at an issue with bacula cloud support which requires md5 calculation and have been trying to use https://github.com/firebladed/bacula/blob/Branch-11.0/bacula/src/lib/md5.c and am getting bad md5 errors from amazon s3
so i tried compiling the code directly into a md5sum executable see (Makefile)
and im getting different md5s from that of ubuntu md5sum
md5sum (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Ulrich Drepper, Scott Miller and David Madore.
Example File that gets wrong md5
2521308b3fe3836623f78708a5c988d6 - ubuntu md5sum
e972192662d26a25af5fb895cf79b175 - compiled md5sum
am testing with simple command line
./md5sum <file>
for compiled md5sum
md5sum <file>
for system md5sum
using the linked example
ideally if its something simple id like to fix it
Your input file contains 0x00
bytes, whereas the program uses while(fgets(buf, ...)) } { MD5Update(..., strlen(buf)) }
. strlen
reports smaller size than the "line" length (your input file seems to be binary), so the generated md5sum is of a different set of bytes.
Convert your input data to text (cat -v part.1
) and pass then to both programs, or fix the program with something along for (int c; (c = fgetc(file)) != EOF; ) MD5Update(&ctx. &c, 1)
.