SHA3_512StreamRange

Cryptography

Description

Computes the SHA3-512 digest over two byte ranges of a stream and packs the 64-byte digest into an AnsiString

The absorbed input is the byte range [0, FirstLength) followed by the byte range [SecondStart, SecondStart + SecondLength), matching the PDF signature /ByteRange layout where the /Contents hole must be skipped; the result is raw binary with one digest byte per character, not hexadecimal text

Syntax

Delphi

Function SHA3_512StreamRange(Input: TStream; FirstLength, SecondStart, SecondLength: Int64): AnsiString;

Parameters

InputStream to hash; the function seeks before each segment, so the stream position on entry does not matter, and a nil stream yields an empty string
FirstLengthNumber of bytes absorbed from stream position 0, the half-open range [0, FirstLength); 0 skips the first segment and a negative value aborts with an empty string
SecondStartStream offset where the second absorbed segment begins, normally the first byte after the signature /Contents hole; a negative value aborts with an empty string
SecondLengthNumber of bytes absorbed from SecondStart, the half-open range [SecondStart, SecondStart + SecondLength); 0 skips the second segment and a negative value aborts with an empty string

Return values

The raw 64-byte SHA3-512 digest packed into an AnsiString, or an empty string when the stream is nil, any range value is negative, or a read returns fewer bytes than requested

Remarks

Runs the built-in FIPS 202 Keccak implementation with the SHA-3 domain suffix and a 72-byte rate, absorbing in 64 KB chunks; each read is verified against the requested count so a truncated stream aborts cleanly, which the SHA-2 stream variants do not do

Example

Digest:= SHA3_512StreamRange(FS, ByteRange[0], ByteRange[2], ByteRange[3]);

See also

SHA256ByteArray, SHA384ByteArray, SHA512ByteArray, SHA3_256ByteArray, SHA3_384ByteArray, SHA3_512ByteArray, SHA1StreamRange, SHA256StreamRange, SHA384StreamRange, SHA512StreamRange, SHA3_256StreamRange, SHA3_384StreamRange, SHAKE256ByteArray, SHAKE256StreamRange