THotPDF.CryptKeyLength Property

Usare CryptKeyLength per scegliere la revisione standard security handler e il cifrario usati quando ActivateProtection e abilitato

 

Significato del valore


k40                        Standard security handler V=1, R=2, RC4 with a 40-bit key (PDF 1.1+).

k128                        Standard security handler V=2, R=3, RC4 with a 128-bit key (PDF 1.4+).

aes128 usa lo standard security handler V=4, R=4 con crypt filter StdCF (CFM=AESV2). AES-128 in modalità CBC con padding PKCS#7 e vettore di inizializzazione casuale a 16 byte secondo ISO 32000-1 7.6.2 / 7.4.4.2 (PDF 1.6+). Da HotPDF v2.4.0 questa opzione cifra stringhe e stream con una vera implementazione AES; le build precedenti emettevano il dizionario AES ma non cifravano realmente il contenuto

aes256 usa lo standard security handler V=5 con crypt filter StdCF (CFM=AESV3). AES-256 in modalità CBC con padding PKCS#7 e vettore di inizializzazione casuale a 16 byte secondo Adobe Extension Level 3 / ISO 32000-2 7.6.4 (PDF 1.7+, accettato da Acrobat 9 e successivi, Foxit, Chrome e visualizzatori Apple/macOS). Disponibile da HotPDF v2.17.0. La revisione predefinita è R=5 con hashing password SHA-256. Impostare UseAES256R6 su true per passare a R=6 con l'algoritmo ISO 32000-2 2.B "hash dance" (SHA-256 / SHA-384 / SHA-512 + mixer AES-128); R=6 è richiesto da Acrobat DC e dai validatori PDF/A-4. Disponibile da HotPDF v2.22.0

 

Public-Key Security Handler (PDF 1.7 7.6.5)

For certificate-based encryption (one document, multiple recipients) call EnablePubKeyEncryption(seed, KeyType, EncryptMetadata) instead of setting UserPassword / OwnerPassword. The same CryptKeyLength values apply to the symmetric cipher (k40 -> RC4-40 / V=1 + s4 SubFilter, k128 -> RC4-128 / V=2 + s5, aes128 -> AES-128 / V=4 + s5). Caller must build one PKCS#7 envelopedData blob per recipient (Windows CryptoAPI, OpenSSL, or pycryptodome) and append each blob through AddPubKeyRecipient; the file encryption key derives through algorithm 9 (SHA-1 of seed concatenated with the envelope binaries). Available since HotPDF v2.33.0.

 

Example di codice

HPDF.OwnerPassword := 'password';          // Set owner password (required to change security settings)
HPDF.UserPassword := 'user';               // Set user password (required to open the document)
HPDF.ProtectOptions := [poEdit, poAnnot];  // Disallow editing and annotations
HPDF.ActivateProtection := true;           // Enable PDF security

 

Vedi anche: ActivateProtection, OwnerPassword, ProtectOptions, UserPassword