pub struct Decryptor { /* private fields */ }Expand description
A built Standard-security-handler decryptor for one file.
Implementations§
Source§impl Decryptor
impl Decryptor
Sourcepub fn from_encrypt_dict(
dict: &PdfDict,
id_first: &[u8],
encrypt_id: Option<ObjectId>,
password: &[u8],
) -> BuildResult
pub fn from_encrypt_dict( dict: &PdfDict, id_first: &[u8], encrypt_id: Option<ObjectId>, password: &[u8], ) -> BuildResult
Build a decryptor from the /Encrypt dictionary, the first element of the
trailer /ID, and a user/owner password (empty for the default open).
The password is authenticated against /U (user) and /O (owner). A
non-empty password that matches neither yields [BuildResult::WrongPassword].
The empty-password default preserves the lenient behavior: an RC4 document
whose /U does not validate still opens (best-effort, with a warning),
since malformed-but-empty-password files are common.
Sourcepub fn decrypt_object(&self, obj: &mut PdfObject, id: ObjectId)
pub fn decrypt_object(&self, obj: &mut PdfObject, id: ObjectId)
Recursively decrypt every string and stream contained in obj, in place,
using the per-object key derived from id. No-op for the /Encrypt
object itself.
Sourcepub fn decrypt_stream_bytes(&self, id: ObjectId, data: &[u8]) -> Vec<u8> ⓘ
pub fn decrypt_stream_bytes(&self, id: ObjectId, data: &[u8]) -> Vec<u8> ⓘ
Decrypt a raw stream byte buffer with the per-object key for id. Used
for the /Type /ObjStm container, which is decrypted directly (not via
decrypt_object) before its filter pipeline.
Sourcepub fn encrypt_stream_bytes(&self, id: ObjectId, data: &[u8]) -> Vec<u8> ⓘ
pub fn encrypt_stream_bytes(&self, id: ObjectId, data: &[u8]) -> Vec<u8> ⓘ
Encrypt a stream payload for object id (the write-side inverse of
Self::decrypt_stream_bytes). Used by the incremental writer to add
objects to an already-encrypted document with its existing key.
Sourcepub fn encrypt_string_bytes(&self, id: ObjectId, data: &[u8]) -> Vec<u8> ⓘ
pub fn encrypt_string_bytes(&self, id: ObjectId, data: &[u8]) -> Vec<u8> ⓘ
Encrypt a string payload for object id.
Sourcepub fn encrypt_object_strings(&self, obj: &mut PdfObject, id: ObjectId)
pub fn encrypt_object_strings(&self, obj: &mut PdfObject, id: ObjectId)
Recursively encrypt every string in obj in place with the per-object
key for id. Stream payloads are NOT touched (they are encrypted
separately via Self::encrypt_stream_bytes, since writers carry the
payload out-of-band).