Skip to main content

compute_encryption_key

Function compute_encryption_key 

Source
pub fn compute_encryption_key(
    password: &[u8],
    owner_key: &[u8],
    permissions: i32,
    file_id: &[u8],
    revision: u32,
    key_length: usize,
    encrypt_metadata: bool,
) -> Vec<u8> 
Expand description

Compute the encryption key from a password (Algorithm 2).

PDF Spec: Section 7.6.3.3 - Algorithm 2: Computing an encryption key

§Arguments

  • password - User or owner password (up to 32 bytes)
  • owner_key - 32-byte owner password hash from encryption dictionary
  • permissions - User access permissions (P field)
  • file_id - First element of file identifier array
  • revision - Encryption revision number (R field)
  • key_length - Key length in bytes
  • encrypt_metadata - Whether to encrypt metadata

§Returns

The derived encryption key