* @param in
* @return
* @throws NoSuchAlgorithmException
* @throws IOException
*/
public static String getFileInputStreamMD5(InputStream in) throws NoSuchAlgorithmException, IOException {
MessageDigest digest = null;
byte buffer[] = new byte[1024];
int len;
digest = MessageDigest.getInstance(MD5);
while ((len = in.read(buffer, 0, LENGTH)) != -1) {
digest.update(buffer, 0, len);
}
in.close();
BigInteger bigInt = new BigInteger(1, digest.digest());
return bigInt.toString(16);
}
}
閱讀更多 代碼專家 的文章