import com.google.common.hash.HashCode; import com.google.common.hash.Hashing; import com.google.common.io.Files; import org.apache.commons.codec.digest.DigestUtils; import java.io.File; import java.io.IOException; /** * @date 2018/7/18 */ public class MD5Utils { public static String getFileMD5(String filePath) throws IOException { File file = new File(filePath); HashCode hashCode = Files.hash(file, Hashing.md5()); return hashCode.toString(); } public static String genMd5OfString(String str){ return DigestUtils.md5Hex(str); } }