Returns the MD5 Checksum of the input stream

@param is
the input stream

@return the Checksum of the input stream
@throws IOException
if an IO exception occurs
161233
public static String getMD5Checksum(InputStream is) throws IOException {

		byte[] digest = null;
		try {
			MessageDigest md = MessageDigest.getInstance(JawrConstant.MD5_ALGORITHM);
			InputStream digestIs = new DigestInputStream(is, md);
			// read stream to EOF as normal...
			while (digestIs.read() != -1) {

			}
			digest = md.digest();
		} catch (NoSuchAlgorithmException e) {
			throw new BundlingProcessException("MD5 algorithm needs to be installed", e);
		}

		return new BigInteger(1, digest).toString(16);
	}
1249633
public static byte[] readBytesFromOtherInputStream(InputStream is) throws IOException
    {
        ByteArrayOutputStream data = new ByteArrayOutputStream();

        int readBytes;
        byte[] buffer = new byte[Math.max(is.available(), 4096)]; // 最低4KB的缓冲区

        while ((readBytes = is.read(buffer, 0, buffer.length)) != -1)
        {
            data.write(buffer, 0, readBytes);
        }

        data.flush();

        return data.toByteArray();
    }
973419
protected int readByte(InputStream is) throws IOException
   {
      byte[] data = new byte[1];
      if (is.read(data) != data.length)
      {
         throw new EOFException();
      }

      return (MPPUtility.getByte(data, 0));
   }
30999
public static String getMD5Checksum(String str, Charset charset) throws IOException {

		InputStream is = new ByteArrayInputStream(str.getBytes(charset.name()));
		return getMD5Checksum(is);
	}
452869
public static String md5(String s) {
		if (s == null) {
			return "";
		}
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			md.update(s.getBytes());

			byte[] byteData = md.digest();

			//convert the byte to hex format method 1
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < byteData.length; i++) {
				sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
			}
			return sb.toString();
		} catch (NoSuchAlgorithmException ex) {
			return "";
		}
	}
379488
private static String getBOMEncoding(final BufferedInputStream is) throws IOException {
        String encoding = null;
        final int[] bytes = new int[3];
        is.mark(3);
        bytes[0] = is.read();
        bytes[1] = is.read();
        bytes[2] = is.read();

        if (bytes[0] == 0xFE && bytes[1] == 0xFF) {
            encoding = UTF_16BE;
            is.reset();
            is.read();
            is.read();
        } else if (bytes[0] == 0xFF && bytes[1] == 0xFE) {
            encoding = UTF_16LE;
            is.reset();
            is.read();
            is.read();
        } else if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) {
            encoding = UTF_8;
        } else {
            is.reset();
        }
        return encoding;
    }
1126370
public static byte[] readStream(InputStream is) throws IOException {
		try {
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			byte[] buf = new byte[1024 * 10];
			int read;
			while ((read = is.read(buf)) >= 0) {
				baos.write(buf, 0, read);
			}
			return baos.toByteArray();
		} finally {
			is.close();
		}
	}
862769
def file_checksum(filepath):
    
    checksum = hashlib.md5()
    with open(filepath, 'rb') as f:
        for fragment in iter(lambda: f.read(65536), ''):
            checksum.update(fragment)
    return checksum.hexdigest()
962995
public static String md5(final String message) {
        byte[] res;

        try {
            MessageDigest instance = MessageDigest.getInstance("MD5");
            instance.reset();
            instance.update(message.getBytes());
            res = instance.digest();

        } catch (final NoSuchAlgorithmException ex) {
            throw new RuntimeException(ex);
        }

        StringBuilder hexString = new StringBuilder();
        for (byte resByte : res) {
            hexString.append(Integer.toString((resByte & 0xff) + 0x100, 16).substring(1));
        }

        return hexString.toString();
    }
990653
public static String sha1(InputStream is) {
		byte[] buf = new byte[1024*1024*5];
		int bytesRead = 0;
		MessageDigest md;
		try {
			md = MessageDigest.getInstance("SHA1");
		} catch (NoSuchAlgorithmException nsae) {
			throw new RuntimeIOException(nsae.getMessage(), nsae);
		}
		try {
			while ((bytesRead = is.read(buf)) > 0) {
				md.update(buf, 0, bytesRead);
			}
		} catch (IOException ioe) {
			throw new RuntimeIOException(ioe.getMessage(), ioe);
		}
		byte[] digest = md.digest();
		String hexDigest = new String(Hex.encodeHex(digest));
		return hexDigest;
	}
9465
@Override
	public int read (byte bytes[], int offset, int length) throws IOException {
		int	r;

		if ((r = in.read(bytes, offset, length)) == -1) return -1;

		md5.Update(bytes, offset, r);

		return r;
	}
631539
public static String getMD5(String md5Salt) {
		try {
			MessageDigest md = MessageDigest.getInstance(MD5);
			byte[] array = md.digest(md5Salt.getBytes(UTF8));
			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < array.length; ++i) {
				sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
			}
			return sb.toString();
		} catch (java.security.NoSuchAlgorithmException e) {
			LOG.error(e.getMessage());
		} catch (UnsupportedEncodingException e) {
			LOG.error(e.getMessage());
		}
		return null;
	}
461401
private static byte[] readAll(InputStream is) throws IOException {
    ByteArrayOutputStream tmp = new ByteArrayOutputStream();

    byte[] buf = new byte[2000];
    int read = 0;
    do {
      read = is.read(buf);
      tmp.write(buf, 0, read);
    } while ((read > 0) && (is.available() > 0));
    return tmp.toByteArray();
  }
675313
def get_checksum(self):
        """"""
        with open(self.file, 'rb') as f:
            cs = md5(f.read()).hexdigest()
        return cs
1372632
private static byte[] readAllBytes(InputStream is) throws IOException {
        byte[] buffer = new byte[8192];
        ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
        int n;
        while ((n = is.read(buffer)) != -1) {
            baos.write(buffer, 0, n);
        }
        return baos.toByteArray();
    }
517806
public static final byte[] readAllBytes(InputStream is) throws IOException
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buf = new byte[4096];
        int rc = is.read(buf);
        while (rc != -1)
        {
            baos.write(buf, 0, rc);
            rc = is.read(buf);
        }
        return baos.toByteArray();
    }
892244
public static byte[] computeMD5Hash(byte[] input) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            return md.digest(input);
        } catch (NoSuchAlgorithmException e) {
            // should never get here
            throw new IllegalStateException(e);
        }
    }