Security
AESCipher
AESCipher ทําการเข้ารหัส AES ในโหมด CBC สําหรับ array byte ที่ถูกนําไปใช้ใน เอกสาร PDF.
byte[] key = ...; // 128, 192, or 256-bit key
byte[] data = "sensitive data".getBytes();
byte[] ciphertext = AESCipher.encrypt(key, data);
byte[] plaintext = AESCipher.decrypt(key, ciphertext);สําหรับการเข้ารหัสแบบกําหนดด้วยเวกเตอร์เริ่มต้นอย่างชัดเจน:
byte[] iv = new byte[16]; // 128-bit IV
byte[] ciphertext = AESCipher.encryptWithIV(key, iv, data);
byte[] plaintext = AESCipher.decryptWithIV(key, iv, ciphertext);PdfFile ความปลอดภัย
PdfFileSecurity การจัดการการเข้ารหัสผ่านระดับเอกสาร และอนุญาตทางเข้า. การ encryptFile() วิธีการรับคําแปลของผู้ใช้, คําแท้เจ้าของ, DocumentPrivilege อัตถุและขนาดของกุญแจ.
try (PdfFileSecurity security = new PdfFileSecurity("input.pdf", "secured.pdf")) {
DocumentPrivilege priv = DocumentPrivilege.getForbidAll();
priv.setAllowPrint(true);
security.encryptFile("userPass", "ownerPass", priv, KeySize.x256);
}decryptFile(ownerPassword) ถอดการเข้ารหัสจากเอกสารที่เข้ากรหิต.
DocumentPrivilege
DocumentPrivilege แสดงให้เห็นถึงการอนุญาตของเอกสารที่เข้ารหัส. การใช้งาน getAllowAll() ให้การอนุญาตทั้งหมด, getForbidAll() หรือปฏิเสธทั้งหมด กําหนดอนุญาตส่วนตัวผ่าน setAllowPrint(), setAllowModifyContents(), setAllowCopy(),และ setAllowModifyAnnotations().
อัลโกริธม Enum
การ Algorithm enum เลือกครอบครัวอัลโกริตม์การรหัส:
Algorithm.RC4การรหัสสตรีม RC4 ที่เก่าแก่Algorithm.AESรหัสบล็อก AES (แนะนํา)