Table of contents
Namespace: Com\Tecnick\Pdf\Encrypt
abstract class Compute extends Data
Extends: Data
Source: src/Compute.php:38
Computes the PDF encryption data.
Methods
encrypt()
Encrypt data using the specified encrypt type.
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): Object number.$gennum(int): Object generation number.
Returns: string
Throws:
Source: src/Compute.php:51
getEncPermissionsString()
Convert encryption P value to a string of bytes, low-order byte first.
public getEncPermissionsString(int $protection): string
Parameters:
$protection(int): 32bit encryption permission value (P value).
Returns: string
Source: src/Compute.php:239
getObjectKey()
Compute encryption key depending on object number where the encrypted data is stored.
This is used for all strings and streams without crypt filter specifier.
public getObjectKey(int $objnum, int $gennum = 0): string
Parameters:
$objnum(int): Object number.$gennum(int): Object generation number.
Returns: string
Throws:
- Exception: When either number is out of range.
Source: src/Compute.php:211
getPubKeyPermissionsString()
Convert encryption P value to the four bytes carried by a public-key recipient envelope, high-order byte first.
The byte order is the opposite of the /P key material of getEncPermissionsString().
public getPubKeyPermissionsString(int $protection): string
Parameters:
$protection(int): 32bit encryption permission value (P value).
Returns: string
Source: src/Compute.php:253
getUserPermissionCode()
Return the permission code used on encryption (P value).
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.
public getUserPermissionCode(string[] $permissions, int $mode): int
Parameters:
$permissions(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.
Returns: int
Throws:
- Exception: When a permission name is not recognised.
Source: src/Compute.php:285
Inherited members
From Data
- DEFAULTPERMS: Permission set applied when the caller does not choose one.
From Output
- __debugInfo(): Redact the file encryption key and the passwords when the object is dumped.
- escapeString(): Escape a string: add “" before “", “(” and “)”.
- getPdfEncryptionObj(): Get the PDF encryption block