Security
AESCIPHER
AESCipher triển khai mã hóa AES trong chế độ CBC cho các rào byte được tích hợp vào PDF tài liệu.
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);Đối với mã hóa định kỳ với một vector khởi động rõ ràng:
byte[] iv = new byte[16]; // 128-bit IV
byte[] ciphertext = AESCipher.encryptWithIV(key, iv, data);
byte[] plaintext = AESCipher.decryptWithIV(key, iv, ciphertext);PdfFileĐiểm bảo mật
PdfFileSecurity quản lý mã hóa mật khẩu cấp tài liệu và quyền truy cập. Các encryptFile() phương pháp chấp nhận mật khẩu người dùng, mật mã chủ sở hữu, DocumentPrivilege - Mục tiêu và kích thước chìa khó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) xóa mã hóa từ một tài liệu được mã hoá.
DocumentPrivilege
DocumentPrivilege đại diện cho lá cờ giấy phép cho tài liệu mã hóa. Sử dụng getAllowAll() để cấp tất cả các giấy phép, getForbidAll() để phủ nhận tất cả, hoặc - Tạo các giấy phép cá nhân qua setAllowPrint(), setAllowModifyContents(), setAllowCopy(), và setAllowModifyAnnotations().
Khảo thuật Enum
Các Algorithm enum chọn gia đình thuật toán mã hóa:
Algorithm.RC4- Tính năng RC4 Stream CipherAlgorithm.AES- AES block cipher (được đề xuất)