/**
* Compute md5 hash of given stream
*
* @param stream stream to hash
* @return hex string md5 hash
* @throws NoSuchAlgorithmException
* @throws IOException
*/
public static String md5HashStream(InputStream stream) throws NoSuchAlgorithmException, IOException {
MessageDigest digest = MessageDigest.getInstance("MD5");
try (DigestInputStream expectDigestStream = new DigestInputStream(stream, digest)) {
int read = 0;
while ((read = expectDigestStream.read()) >= 0) {
// don't care about the data
}
}
return new HexBinaryAdapter().marshal(digest.digest());
}
Utils.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:camel-isds
作者:
评论列表
文章目录