Java MD5 Stream computeMD5Hash(InputStream is)

Here you can find the source of computeMD5Hash(InputStream is)

Description

compute MD Hash

License

Apache License

Declaration

public static byte[] computeMD5Hash(InputStream is) throws NoSuchAlgorithmException, IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static byte[] computeMD5Hash(InputStream is) throws NoSuchAlgorithmException, IOException {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        byte[] buffer = new byte[1024 * 1024];
        int bytesRead;
        while ((bytesRead = is.read(buffer, 0, buffer.length)) != -1) {
            messageDigest.update(buffer, 0, bytesRead);
        }//from www  .  ja v a 2s .co m
        return messageDigest.digest();
    }
}

Related

  1. computeMd5(InputStream is)
  2. computeMD5(InputStream message)
  3. computeMD5checksum(InputStream input)
  4. computeMd5Hash(InputStream is)
  5. computeMD5Hash(InputStream is)