Security

AESCipher (Sistem Informasi dan Komunikasi)

AESCipher menerapkan enkripsi AES dalam mode CBC untuk array byte yang tertanam di Dokumen 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);

Untuk enkripsi deterministik dengan vektor inisialisasi eksplisit:

byte[] iv = new byte[16]; // 128-bit IV
byte[] ciphertext = AESCipher.encryptWithIV(key, iv, data);
byte[] plaintext  = AESCipher.decryptWithIV(key, iv, ciphertext);

PdfFileSecurity (Keamanan File)

PdfFileSecurity mengelola enkripsi kata sandi dan izin akses tingkat dokumen. Pengelolaan encryptFile() metode menerima kata sandi pengguna, password pemilik, DocumentPrivilege objek, dan ukuran kunci.

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) menghapus enkripsi dari dokumen yang dienkripsi.

DocumentPrivilege

DocumentPrivilege mewakili tanda izin untuk dokumen yang dienkripsi. Penggunaan getAllowAll() untuk memberikan semua izin, getForbidAll() untuk menyangkal semua, atau mengatur izin individual melalui setAllowPrint(), setAllowModifyContents(), setAllowCopy(), dan setAllowModifyAnnotations().

Algoritma Enum

Pengelolaan Algorithm enum memilih keluarga algoritma kriptografi:

  • Algorithm.RC4 cipher RC4 yang sudah ada
  • Algorithm.AES AES blok cipher (disarankan)

See Also

 Bahasa Indonesia