Here you can find the source of digest(final InputStream inputStream, final MessageDigest digester)
public static InputStream digest(final InputStream inputStream, final MessageDigest digester)
//package com.java2s; //License from project: LGPL import java.io.IOException; import java.io.InputStream; import java.security.*; public class Main { public static InputStream digest(final InputStream inputStream, final MessageDigest digester) { return new DigestInputStream(removeOSSpecificChars(inputStream), digester); }//ww w.ja va 2 s. co m private static InputStream removeOSSpecificChars(final InputStream inputStream) { return new InputStream() { @Override public int read() throws IOException { do { final byte next = (byte) inputStream.read(); if (!isOsSpecificChar(next)) { return next; } } while (true); } }; } /** * EBICS Specification 14 Appendix: Signature process for the electronic signature: * <p></p> * <p>The characters restricted to the operating system (CR, LF and Ctrl-Z) are not included in the calculation * of hash values of the A005/A006 ES (analogous to A004 ES).</p> * * @param octet the byte * @return <code>true</code> if the octet reflects an OS specific character */ static boolean isOsSpecificChar(final byte octet) { switch (octet) { case '\r': // CR case '\n': // LF case 0x1A: // CTRL-Z / EOF return true; default: return false; } } }