Compute

Computes the PDF encryption data.

Namespace: Com\Tecnick\Pdf\Encrypt

Extends: Data

Abstract: Yes

File: Compute.php line 38

Computes the PDF encryption data.

Tags

Constants

DEFAULTPERMS

File: Data.php line 63

public array<string|int, string> DEFAULTPERMS = ['print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high']

Methods

__debugInfo()

File: Output.php line 131

public __debugInfo() : array<string, mixed>

Return values

array<string, mixed>

encrypt()

File: Compute.php line 51

public encrypt(int|string $type[, string $data = '' ][, string $key = '' ][, int $objnum = 0 ][, int $gennum = 0 ]) : string

Parameters

  • $type : int|string: Encrypt type.
  • $data : string = ‘’: Data string to encrypt.
  • $key : string = ‘’: Encryption key.
  • $objnum : int = 0: Object number.
  • $gennum : int = 0: Object generation number.

Tags

Return values

string

escapeString()

File: Output.php line 146

public escapeString(string $str) : string

Parameters

  • $str : string: String to escape.

Return values

string

getEncPermissionsString()

File: Compute.php line 239

public getEncPermissionsString(int $protection) : string

Parameters

  • $protection : int: 32bit encryption permission value (P value).

Return values

string

getObjectKey()

File: Compute.php line 211

public getObjectKey(int $objnum[, int $gennum = 0 ]) : string

This is used for all strings and streams without crypt filter specifier.

Parameters

  • $objnum : int: Object number.
  • $gennum : int = 0: Object generation number.

Tags

  • throws: Exception When either number is out of range.

Return values

string

getPdfEncryptionObj()

File: Output.php line 186

public getPdfEncryptionObj(int &$pon) : string

Parameters

  • $pon : int: Current PDF object number

Tags

  • throws: Exception When encryption is not enabled.

Return values

string

getPubKeyPermissionsString()

File: Compute.php line 253

public getPubKeyPermissionsString(int $protection) : string

The byte order is the opposite of the /P key material of getEncPermissionsString().

Parameters

  • $protection : int: 32bit encryption permission value (P value).

Return values

string

getUserPermissionCode()

File: Compute.php line 285

public getUserPermissionCode(array<string|int, string> $permissions, int $mode) : int

The returned value is a signed 32-bit integer as required by Table 22: reserved bits 7, 8 and 13 to 32 are set, bits 1 and 2 are clear, and every granted permission bit is set.

Parameters

  • $permissions : array<string|int, string>: The set of permissions (specify the ones you want to block).
  • $mode : int: Encryption strength: 0 = RC4-40 (deprecated); 1 = RC4-128 (deprecated); 2 = AES-128; 3 = AES-256 R5; 4 = AES-256 R6 (PDF 2.0 / ISO 32000-2). Revision 2 defines fewer permission bits than the others.

Tags

  • throws: Exception When a permission name is not recognised.

Return values

int