No thoughts?

Thanks in advance!



________________________________
 From: John Dhabolt <[email protected]>
To: "[email protected]" <[email protected]> 
Sent: Monday, October 15, 2012 4:53 PM
Subject: AES Encryption Example?
 
Hi,


I've pretty much exhausted my Google search skills in trying to find any posts 
covering AES encryption with PDFBox. I'm looking for the simplest 
implementation.

It appears I need a StandardSecurityHandler or PublicKeySecurityHandler and 
apparently the StandardProtectionPolicy (which is well documented in the 
Encrypt class), but I keep trying to bang them together and nothing useful 
happens.

In one of my clearly naive attempts I do something like this (the only thing 
that isn't based on the Encrypt example is the attempt to use the 
StandardSecurityHandler...obviously incorrectly):

StandardSecurityHandler ssh = new StandardSecurityHandler(spp);
ssh.setKeyLength(KEY_LENGTH);
ssh.setAES(true);

AccessPermission ap = new AccessPermission();
// set various permissions

StandardProtectionPolicy spp = new StandardProtectionPolicy(OWNER_PASSWORD, 
null, ap);
spp.setEncryptionKeyLength(KEY_LENGTH); 

document.setSecurityHandler(ssh); // Seems to be the way to set a security 
handler
document.protect(spp); // Completely ignores AES (I get the default 128-bit RC4 
encryption)

As noted in the comments above, this correctly locks the PDF but sets 128-bit 
RC4 encryption as opposed to AES. 

Thanks in advance for any suggestions.

John

Reply via email to