public static byte[] generateSHA1Hash(ResourceByteRangeProvider resourceByteRangeProvider) throws NoSuchAlgorithmException, IOException {
  MessageDigest md=MessageDigest.getInstance("SHA1");
  long rangeStart=0;
  long rangeEnd=(rangeStart + 1023 > resourceByteRangeProvider.getResourceSize() - 1) ? resourceByteRangeProvider.getResourceSize() - 1 : rangeStart + 1023;
  int nread=0;
  while (rangeStart < resourceByteRangeProvider.getResourceSize() && rangeEnd < resourceByteRangeProvider.getResourceSize()) {
    byte[] dataBytes=resourceByteRangeProvider.getByteRangeAsBytes(rangeStart,rangeEnd);
    nread=(int)(rangeEnd - rangeStart + 1);
    md.update(dataBytes,0,nread);
    rangeStart=rangeEnd + 1;
    rangeEnd=(rangeStart + 1023 > resourceByteRangeProvider.getResourceSize() - 1) ? resourceByteRangeProvider.getResourceSize() - 1 : rangeStart + 1023;
  }
  ;
  byte[] mdbytes=md.digest();
  return Arrays.copyOf(mdbytes,mdbytes.length);
}

public static byte [ ] generateSHA1Hash ( ResourceByteRangeProvider resourceByteRangeProvider ) throws NoSuchAlgorithmException , IOException { MessageDigest md = MessageDigest . getInstance ( "SHA1" ) ; long rangeStart = 0 ; long rangeEnd = ( rangeStart + 1023 > resourceByteRangeProvider . getResourceSize ( ) - 1 ) ? resourceByteRangeProvider . getResourceSize ( ) - 1 : rangeStart + 1023 ; int nread = 0 ; while ( rangeStart < resourceByteRangeProvider . getResourceSize ( ) && rangeEnd < resourceByteRangeProvider . getResourceSize ( ) ) { byte [ ] dataBytes = resourceByteRangeProvider . getByteRangeAsBytes ( rangeStart , rangeEnd ) ; nread = ( int ) ( rangeEnd - rangeStart + 1 ) ; md . update ( dataBytes , 0 , nread ) ; rangeStart = rangeEnd + 1 ; rangeEnd = ( rangeStart + 1023 > resourceByteRangeProvider . getResourceSize ( ) - 1 ) ? resourceByteRangeProvider . getResourceSize ( ) - 1 : rangeStart + 1023 ; } ; byte [ ] mdbytes = md . digest ( ) ; return Arrays . copyOf ( mdbytes , mdbytes . length ) ; }
a method to generate a sha - 1 digest of the incoming resource
