THotPDF.CryptKeyLength Property

 

THotPDF.CryptKeyLength

THotPDF

 

Topo  Anterior  Próximo

Determina o método de criptografia do arquivo PDF.

 

type

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

 

Sintaxe Delphi:

property CryptKeyLength: THPDFKeyType;

 

Sintaxe C++:

__property THPDFKeyType CryptKeyLength;

 

Descrição

Utilize CryptKeyLength para escolher a revisão do standard security handler e a cifra usada quando ActivateProtection está habilitado

 

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 com crypt filter StdCF (CFM=AESV2). AES-128 em modo CBC com padding PKCS#7 e um vetor de inicialização aleatório de 16 bytes conforme ISO 32000-1 7.6.2 / 7.4.4.2 (PDF 1.6+). Desde HotPDF v2.4.0, esta opção criptografa strings e fluxos com uma implementação AES real; versões anteriores emitiam o dicionário AES, mas não criptografavam de fato o conteúdo

aes256 Standard security handler V=5 com crypt filter StdCF (CFM=AESV3). AES-256 em modo CBC com padding PKCS#7 e vetor de inicialização aleatório de 16 bytes conforme Adobe Extension Level 3 / ISO 32000-2 7.6.4 (PDF 1.7+, aceito por Acrobat 9 e posteriores, Foxit, Chrome e visualizadores Apple/macOS). Disponível desde HotPDF v2.17.0. A revisão padrão é R=5 com hash de senha SHA-256. Defina UseAES256R6 como true para alternar para R=6 com o algoritmo 2.B "hash dance" da ISO 32000-2 (SHA-256 / SHA-384 / SHA-512 + misturador AES-128); R=6 é exigido pelo Acrobat DC e por validadores PDF/A-4. Disponível desde 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.

 

Code Example

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

 

Consulte também: ActivateProtection, OwnerPassword, ProtectOptions, UserPassword