ביטחון

אסיפר

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 ניהול ההצפנה של הסיסמה ברמת המסמך והרשאות גישה. The 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

The Algorithm Enum בוחרת את משפחת האלגוריתם הקריפטוגרפי:

  • Algorithm.RC4 רכיבה על RC4 Stream Chipher
  • Algorithm.AES – AES Block Chifer (מומלץ)

ראה גם

 עברית