Skip to content

Instantly share code, notes, and snippets.

@rsatrio
Created May 7, 2022 22:58
Show Gist options
  • Save rsatrio/759bab61b222df5c25d63b5e1da961e4 to your computer and use it in GitHub Desktop.
Save rsatrio/759bab61b222df5c25d63b5e1da961e4 to your computer and use it in GitHub Desktop.
Calculate MD on PDF File
byte[] contentToSigned=getByteRangeData(pdfBytes, signature.getByteRange());
private byte[] getByteRangeData(ByteArrayInputStream bis,int[] byteRange) {
int length1=byteRange[1]+byteRange[3];
byte[] contentSigned=new byte[length1];
bis.skip(byteRange[0]);
bis.read(contentSigned, 0, byteRange[1]);
bis.skip(byteRange[2]-byteRange[1]-byteRange[0]);
bis.read(contentSigned, byteRange[1], byteRange[3]);
bis.reset();
return contentSigned;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment