We're trying to avoid saving duplicate files. However, our md5 result is always different from BlobInfo.
How we calculate it:
MessageDigest messageDigest = java.security.MessageDigest.getInstance("MD5");
digest = messageDigest.digest(bytes);
String digestString = DigestUtils.md5Hex(digest);
It doesn't match:with (new BlobInfoFactory().loadBlobInfo(blobKey)).getMd5Hash();
Example mismatches:
google vs my own calculation:
8cdeb6db94bc4fd156e2975fd8ebbcf2 vs 9003b37afbf3637de96c35774069453f
65a25dafcba58d16d58a9c7585cc3932 vs 52383159f7d27417d50121aaee2728b5
5cccc2d690fdc0c254234d5526876b34 vs 8196da9b6733daa60e08d927693df483
It is on production server. ( we didn't test dev environment )
Sebastian Kreft is right in the above discussion in comments.
The code I copied is wrong. it should just be:
String digestString = DigestUtils.md5Hex(bytes);
Sebastian Kreft used the trick to verify empty file's md5 which should always be d41d8cd98f00b204e9800998ecf8427e!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With