List of utility methods to do MD5 File
String | computeMD5(File file) compute MD if (file == null || file.isDirectory() || !file.exists()) return null; MessageDigest md5Checker; try { md5Checker = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { return null; InputStream fis = null; try { fis = new BufferedInputStream(new FileInputStream(file)); int read = -1; while ((read = fis.read()) != -1) { md5Checker.update((byte) read); byte[] digest = md5Checker.digest(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < digest.length; i++) { if ((digest[i] & 0xFF) < 0x10) buf.append('0'); buf.append(Integer.toHexString(digest[i] & 0xFF)); return buf.toString(); } catch (FileNotFoundException e) { return null; } catch (IOException e) { return null; } finally { if (fis != null) try { fis.close(); } catch (IOException e) { |
String | computeMD5(File file) Computes the MD5 checksum of the given File . if (file == null) { throw new IOException("Can't compute MD5 without a File."); if (!file.isFile()) { throw new IOException("Can't compute MD5, because \"" + file + "\" is not an existing file."); return computeMD5(new FileInputStream(file)); |
String | computeMD5(final File file) Returns MD5 for specified file. return computeMD5(file, MD5_BUFFER_LENGTH);
|
String | computeMD5(String filename) compute MD MessageDigest md = MessageDigest.getInstance("MD5"); FileInputStream ifs = new FileInputStream(filename); ByteArrayOutputStream byteOutput = null; StringBuffer hexString = new StringBuffer(); byte[] bytes = new byte[1024]; int read; byteOutput = new ByteArrayOutputStream(); while ((read = ifs.read(bytes)) > -1) ... |
byte[] | computeMd5Digest(final File file) Returns the MD5 hash of the given file. try (final FileInputStream fis = new FileInputStream(file)) { return computeMd5Digest(fis); |
String | computeMD5Sum(final File file) Compute MD5 sum of a file. if (file == null) { throw new NullPointerException("The file argument is null"); return computeMD5Sum(new FileInputStream(file)); |