public static byte[] digest(final DigestAlgorithm digestAlgorithm,final DSSDocument document) throws DSSException {
  final MessageDigest messageDigest=getMessageDigest(digestAlgorithm);
  byte[] buffer=new byte[1024];
  int count=-1;
  InputStream stream=document.openStream();
  try {
    while ((count=stream.read(buffer)) > 0) {
      messageDigest.update(buffer,0,count);
    }
  }
 catch (  IOException e) {
    throw new DSSException(e);
  }
  final byte[] digestValue=messageDigest.digest();
  return digestValue;
}

public static byte [ ] digest ( final DigestAlgorithm digestAlgorithm , final DSSDocument document ) throws DSSException { final MessageDigest messageDigest = getMessageDigest ( digestAlgorithm ) ; byte [ ] buffer = new byte [ 1024 ] ; int count = - 1 ; InputStream stream = document . openStream ( ) ; try { while ( ( count = stream . read ( buffer ) ) > 0 ) { messageDigest . update ( buffer , 0 , count ) ; } } catch ( IOException e ) { throw new DSSException ( e ) ; } final byte [ ] digestValue = messageDigest . digest ( ) ; return digestValue ; }
this method allows to digest the data with the given algorithm .
