Here you can find the source of md5sum(byte[] input, int length)
public static String md5sum(byte[] input, int length)
//package com.java2s; /*/* w w w.j av a 2 s . c o m*/ This file is part of smpte2022lib. This project is free software: you can redistribute it and/or modify it under the terms of the EUPL v. 1.1 as provided by the European Commission. This project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the European Union Public License for more details. You should have received a copy of the EUPL General Public License along with this project. If not, see he EUPL licence v1.1 is available in 22 languages: 22-07-2013, <https://joinup.ec.europa.eu/software/page/eupl/licence-eupl> Retrieved from https://github.com/davidfischer-ch/smpte2022lib.git */ import java.security.*; public class Main { protected static final String HEXES = "0123456789ABCDEF"; public static String md5sum(byte[] input, int length) { try { MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(input, 0, length); return getHex(md5.digest()); } catch (NoSuchAlgorithmException e) { return null; } } public static String getHex(long raw) { return String.format("%08x", raw); } public static String getHex(byte[] raw) { if (raw == null) return null; final StringBuilder hex = new StringBuilder(2 * raw.length); for (final byte b : raw) { hex.append(HEXES.charAt((b & 0xF0) >> 4)).append( HEXES.charAt((b & 0x0F))); } return hex.toString(); } }