Sécurité
AESCIPHER
AESCipher implémenter la cryptage AES dans le mode CBC pour les arées bytes intégrées dans Documents 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);Pour un chiffrement déterministe avec un vecteur d’initialisation explicite :
byte[] iv = new byte[16]; // 128-bit IV
byte[] ciphertext = AESCipher.encryptWithIV(key, iv, data);
byte[] plaintext = AESCipher.decryptWithIV(key, iv, ciphertext);PdfFileSecurity
PdfFileSecurity Gérer le chiffrement de mot de passe et les permissions d’accès au niveau du document. Le encryptFile() le mode accepte un mot de passe utilisateur, la parole propriétaire, DocumentPrivilege Objet et taille clé.
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) Il supprime la cryptage d’un document chiffré.
DocumentPrivilege
DocumentPrivilege Il représente les drapeaux de l’autorisation pour le document chiffré. Utiliser getAllowAll() pour donner toutes les autorisations, getForbidAll() Pour tout le monde, ou pour - les autorisations individuelles par le biais de setAllowPrint(), setAllowModifyContents(), setAllowCopy(),et setAllowModifyAnnotations().
Algoritme enum
Le Algorithm Enum sélectionne la famille algorithmique cryptographique :
Algorithm.RC4- Récupération RC4 Stream ChipherAlgorithm.AES- AES block cipher (recommandé)