Osiguranje
Uputstvo u skladu s člankom 21. stavkom 1.
AESCipher U ovom slučaju, u skladu s člankom 21. stavkom 1. točkom (a) ovog članka, ako je potrebno, podnosite zahtjev za dopuštenje. PDF dokumenti.
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);U slučaju determinističkog šifriranja s eksplicitnim vektorom inicijalizacije:
byte[] iv = new byte[16]; // 128-bit IV
byte[] ciphertext = AESCipher.encryptWithIV(key, iv, data);
byte[] plaintext = AESCipher.decryptWithIV(key, iv, ciphertext);PdfFileSecurity
PdfFileSecurity Upravlja šifrom lozinke na nivou dokumenta i pristupnim dozvolama. U skladu s člankom 1. encryptFile() metoda prihvaća korisničku lozinku, vlasničku lozicu, DocumentPrivilege predmet, i veličina ključa.
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) uklanja šifriranje sa šifrivanog dokumenta.
DocumentPrivilege
DocumentPrivilege predstavlja oznake za odobrenje šifriranog dokumenta. Upotreba: getAllowAll() da odobri sva ovlaštenja, getForbidAll() da odbiješ sve, ili postaviti pojedinačne dozvole putem: setAllowPrint(), setAllowModifyContents(), setAllowCopy(), i setAllowModifyAnnotations().
Algoritam Enum
U skladu s člankom 1. Algorithm enum odabere obitelj kriptografskih algoritama:
Algorithm.RC4legacy RC4 stream šifriranjeAlgorithm.AESAES blokni šifr (preporučuje se)