19 package org.sleuthkit.datamodel;
21 import java.io.IOException;
22 import java.math.BigInteger;
23 import java.security.MessageDigest;
24 import java.security.NoSuchAlgorithmException;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import java.io.InputStream;
34 private final static int BUFFER_SIZE = 16 * 1024;
47 Logger logger = Logger.getLogger(
HashUtility.class.getName());
49 byte[] buffer =
new byte[BUFFER_SIZE];
50 MessageDigest md = MessageDigest.getInstance(
"md5");
51 int len = in.read(buffer);
53 md.update(buffer, 0, len);
54 len = in.read(buffer);
56 byte[] hash = md.digest();
57 BigInteger bigInt =
new BigInteger(1, hash);
58 hashText = bigInt.toString(16);
60 while (hashText.length() < 32) {
61 hashText =
"0" + hashText;
63 }
catch (NoSuchAlgorithmException ex) {
64 logger.log(Level.WARNING,
"No algorithm known as 'md5'", ex);
81 return md5.toLowerCase().equals(
"d41d8cd98f00b204e9800998ecf8427e");
97 Logger logger = Logger.getLogger(
HashUtility.class.getName());
100 file.getSleuthkitCase().setMd5Hash(file, md5Hash);
102 logger.log(Level.WARNING,
"Error updating content's md5 in database", ex);
static String calculateMd5(AbstractFile file)
static boolean isNoDataMd5(String md5)
static String calculateMd5Hash(Content content)