PDFSM4EncryptToStream

Cryptography

Description

Encrypts a string exactly like PDFSM4EncryptString and writes the IV-prefixed ciphertext to a stream

Syntax

Delphi

Function PDFSM4EncryptToStream(Const Key, Plaintext: AnsiString;
  Target: TStream): Int64;

Parameters

KeyExactly 16 bytes
PlaintextAny length; padded with PKCS#7 before encryption
TargetAssigned stream receiving the IV-prefixed ciphertext

Return values

countThe number of bytes written, matching PDFSM4EncryptedLength(Length(Plaintext))
-1Target is unassigned or the encryption failed

Remarks

The stream is written with WriteBuffer, so an existing position is respected and stream errors raise

See also

PDFSM4EncryptString, PDFSM4DecryptStringBuffer, PDFSM4EncryptedLength