THotPDF.CryptKeyLength – vlastnost

 

THotPDF.CryptKeyLength – vlastnost

THotPDF

 

Nahoru  Předchozí  Další

Determines PDF file encryption method.

 

type

THPDFKeyType = ( k40,  k128,  aes128,  aes256 );

 

Syntaxe Delphi:

property CryptKeyLength: THPDFKeyType;

 

Syntaxe C++:

__property THPDFKeyType CryptKeyLength;

 

Popis

Pomocí CryptKeyLength vyberete revizi standardního security handleru a šifru použitou při zapnutém ActivateProtection

 

Value                Meaning


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 CBC mode with PKCS#7 padding and a 16-byte random initialization vector per ISO 32000-1 7.6.2 / 7.4.4.2 (PDF 1.6+). Since HotPDF v2.4.0 this option encrypts strings and streams with a real AES implementation; earlier builds emitted the AES dictionary but did not actually encrypt content.

aes256                  Standard security handler V=5 with crypt filter StdCF (CFM=AESV3). AES-256 in CBC mode with PKCS#7 padding and a 16-byte random initialization vector per Adobe Extension Level 3 / ISO 32000-2 7.6.4 (PDF 1.7+, accepted by Acrobat 9 and later, Foxit, Chrome and the Apple/macOS viewers). Available since HotPDF v2.17.0. The default revision is R=5 with SHA-256 password hashing. Set 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.

 

Public-Key Security Handler (PDF 1.7 7.6.5)

Pro šifrování založené na certifikátech (jeden dokument, více příjemců) volejte EnablePubKeyEncryption(seed, KeyType, EncryptMetadata) místo nastavování UserPassword / OwnerPassword. Stejné hodnoty CryptKeyLength platí pro symetrickou šifru (k40 -> RC4-40 / V=1 + s4 SubFilter, k128 -> RC4-128 / V=2 + s5, aes128 -> AES-128 / V=4 + s5). Volající musí sestavit jeden blob PKCS#7 envelopedData pro každého příjemce (Windows CryptoAPI, OpenSSL nebo pycryptodome) a každý blob připojit přes AddPubKeyRecipient; šifrovací klíč souboru se odvozuje algoritmem 9 (SHA-1 ze seedu zřetězeného s binárními daty obálek). Dostupné od HotPDF v2.33.0

 

Příklad kódu

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

 

Viz také: ActivateProtection, OwnerPassword, ProtectOptions, UserPassword