SHA1StreamRange

Cryptography

Description

AnsiString

/ByteRangeThe hashed input is the byte range [0, FirstLength) followed by the byte range [SecondStart, SecondStart + SecondLength), matching the PDF signature /Contents layout where the

Syntax

Delphi

Function SHA1StreamRange(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
FirstLengthNumber of bytes hashed from stream position 0, the half-open range [0, FirstLength); 0 skips the first segment
SecondStartStream offset where the second hashed segment begins, normally the first byte after the signature /Contents hole
SecondLengthNumber of bytes hashed from SecondStart, the half-open range [SecondStart, SecondStart + SecondLength); 0 skips the second segment

Return values

The raw 20-byte SHA-1 digest packed into an AnsiString, or an empty string when the CryptoAPI provider or hash object cannot be created or a hash step fails

Remarks

Delegates to the shared SHAStreamRange helper, which acquires a PROV_RSA_AES CryptoAPI context, hashes CALG_SHA1 in chunks of up to 8000 bytes, and ignores the return count of each stream read; negative range values are not rejected by this helper, unlike the SHA-3 stream variants, and SHA-1 is retained for legacy signature interop

Example

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

See also

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