|
Determina il metodo di cifratura del file PDF.
type
THPDFKeyType = ( k40, k128, aes128, aes256, aesgcm );
Sintassi Delphi:
property CryptKeyLength: THPDFKeyType;
Sintassi C++:
__property THPDFKeyType CryptKeyLength;
Descrizione
Usa CryptKeyLength per scegliere la revisione del security handler standard e il cifrario usati quando ActivateProtection è abilitata.
For AES password encryption, set EncryptMetadata to false before BeginDoc to write /EncryptMetadata false, lascia l'XMP /Metadata testo in chiaro, e usa la derivazione di chiave AES-128 corrispondente o AES-256 /Perms dei metadati. Il valore predefinito è true per compatibilità.
Valore Significato
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 Standard security handler V=4, R=4 with crypt filter StdCF (CFM=AESV2). AES-128 in modalità CBC con padding PKCS#7 e un vettore di inizializzazione casuale a 16 byte per ISO 32000-1 7.6.2 / 7.4.4.2 (PDF 1.6+). Dalla 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 davvero il contenuto.
aes256 Standard security handler V=5 with crypt filter StdCF (CFM=AESV3). AES-256 in modalità CBC con padding PKCS#7 e un vettore di inizializzazione casuale di 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 i viewer Apple/macOS). Disponibile dalla HotPDF v2.17.0. La selezione di aes256 porta la versione di output a PDF 1.7 quando è più bassa, a meno che StrictVersionLock sia impostato, nel qual caso una versione più bassa fa fallback ad AES-128 (prima della v2.760.0 l'output predefinito PDF 1.6 ricadeva silenziosamente su AES-128). La revisione predefinita è R=5 con hashing delle password SHA-256. Imposta UseAES256R6 to true to switch to R=6 with the ISO 32000-2 algorithm 2.B "hash dance" (SHA-256 / SHA-384 / SHA-512 + AES-128 mixer); R=6 is required by Acrobat DC and PDF/A-4 validators. Available since HotPDF v2.22.0.
aesgcm Standard security handler V=6, R=7 with crypt filter StdCF (CFM=AESV4). AES-256-GCM usa un vettore di inizializzazione univoco di 12 byte e un tag di autenticazione di 16 byte per ogni stringa e stream cifrati, con dati autenticati aggiuntivi vuoti, come definito da ISO/TS 32003:2023. Questa opzione richiede PDF 2.0 ed emette l'estensione per sviluppatori ISO al livello di estensione 32003. Disponibile dalla HotPDF v2.475.0.
Public-Key Security Handler (ISO 32000-1 7.6.4, ISO 32000-2 7.6.5)
For certificate-based encryption (one document, multiple recipients) call EnablePubKeyEncryption(seed, KeyType, EncryptMetadata) invece di impostare UserPassword / OwnerPassword. La cifratura a chiave pubblica supporta k40, k128, aes128 e aes256 (aes256 porta l'output a PDF 2.0, e i destinatari basati su certificato o su key agreement lo richiedono); aesgcm è limitato al security handler standard basato su password. Il chiamante deve costruire un blob PKCS#7 envelopedData per destinatario (Windows CryptoAPI, OpenSSL o pycryptodome) e accodare ogni blob tramite AddPubKeyRecipient; the file encryption key derives as described in ISO 32000-1 7.6.4.3 (SHA-1 of seed concatenated with the envelope binaries). Available since HotPDF v2.33.0.
Esempio di codice
HPDF.Version := pdf20; // Select PDF 2.0
HPDF.CryptKeyLength := aesgcm; // Select AES-256-GCM
HPDF.OwnerPassword := 'password'; // Set owner password (required to change security settings)
HPDF.UserPassword := 'user'; // Set user password (required to open the document)
HPDF.ProtectOptions := [prPrint, prPrint12bit]; // Allow full-quality printing only
HPDF.EncryptMetadata := false; // Keep XMP metadata cleartext
HPDF.ActivateProtection := true; // Enable PDF security
Vedi anche: ActivateProtection, OwnerPassword, ProtectOptions, UserPassword
|