TSHA256Digest = array[0..31] of Byte;
TSHA256Context = record
State: array[0..7] of Cardinal;
Buffer: array[0..63] of Byte;
BufCnt: Cardinal;
Length: UInt64;
end;
procedure SHA256Init(out Ctx: TSHA256Context);
procedure SHA256Update(var Ctx: TSHA256Context; const Buf; BufLen: Cardinal);
procedure SHA256Final(var Ctx: TSHA256Context; out Digest: TSHA256Digest);
function SHA256Bytes(const B: TBytes): TSHA256Digest;
function SHA256Of(const Buf; BufLen: Cardinal): TSHA256Digest;
function SHA256Hex(const Digest: TSHA256Digest): string;
FPdfSha256 is the SHA-256 hash implementation used throughout the PDFium Delphi Component signing and encryption stack. It is required because Free Pascal does not ship a SHA-2 unit, and bundling it keeps the library dependency-free on all supported compilers
The incremental SHA256Init / SHA256Update / SHA256Final API hashes data larger than memory or streamed in chunks. SHA256Bytes and SHA256Of are one-shot helpers over a byte array or an untyped buffer, and SHA256Hex formats a digest as a lowercase 64-character hex string
The TSHA256Digest type is consumed by FPdfCms, FPdfTsa, and FPdfCryptoWin as the digest shape for signed-attribute hashing
| Function | Description |
|---|---|
SHA256Init | Initializes a hashing context |
SHA256Update | Feeds an untyped buffer into an open context |
SHA256Final | Finalizes the context and returns the 32-byte digest |
SHA256Bytes | One-shot hash of a byte array |
SHA256Of | One-shot hash of an untyped buffer of a given length |
SHA256Hex | Formats a digest as a lowercase hex string |
| Type | Description |
|---|---|
TSHA256Digest | 32-byte SHA-256 digest consumed by the CMS, TSA, and crypto units |
TSHA256Context | Incremental hashing context holding the working state, message block buffer, byte count, and total length |
| Field | Description |
|---|---|
State | Eight 32-bit working words that accumulate the hash; SHA256Init loads the FIPS 180-4 initial values, every absorbed 64-byte block updates them, and SHA256Final emits them big-endian as the digest |
Buffer | Staging area holding the bytes of the current incomplete 64-byte message block between SHA256Update calls |
BufCnt | Number of message bytes currently staged in Buffer, ranging from 0 to 63 |
Length | Total number of message bytes absorbed so far; SHA256Final converts it to a bit count for the 64-bit big-endian length trailer |