/** * Calculates the MD5 digest and returns the value as a 16 element <code>byte[]</code>. * @param data data to digest * @return MD5 digest */ public static byte[] md5(byte[] data) { return getMd5Digest().digest(data); }
/** * Calculates the MD5 digest and returns the value as a 16 element <code>byte[]</code>. * @param data data stream to digest (will not be closed) * @return MD5 digest */ public static byte[] md5(InputStream data) throws IOException { MessageDigest md = getMd5Digest(); final byte[] buf = new byte[1024 * 4]; for (int v; (v = data.read(buf)) >= 0;) { if (v > 0) md.update(buf, 0, v); } return md.digest(); }