الأمن
AESCipher (مخططات الإلكترونية)
AESCipher تنفيذ تشفير AES في وضع CBC لمصفوفات بايت مدمجة في وثائق 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);PdfFileSecurity
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 (موصى بها)