---
title: ByteExtensions
summary: API reference for ByteExtensions.
status: draft
owner: saif-docgen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common
reference_type: package
---

# ByteExtensions

Byte-array helpers for locating a known signature (e.g. a PDF header), stripping a leading header, and hashing a payload. ([BR-053](../../business-rules.md#br-053-a-string-search-pattern-over-a-binary-payload-is-encoded-as-ascii%2C-not-unicode), [BR-054](../../business-rules.md#br-054-a-byte-search-returns--1-when-the-haystack-is-empty%2C-the-needle-is-empty%2C-the-needle-is-longer-than-the-haystack%2C-or-the-start-offset-leaves-too-few-bytes), [BR-056](../../business-rules.md#br-056-a-header-is-stripped-only-when-the-signature-is-found-at-a-position-greater-than-zero))

## Purpose
- Byte-array helpers for locating a known signature (e.g. a PDF header), stripping a leading header, and hashing a payload. ([BR-053](../../business-rules.md#br-053-a-string-search-pattern-over-a-binary-payload-is-encoded-as-ascii%2C-not-unicode), [BR-054](../../business-rules.md#br-054-a-byte-search-returns--1-when-the-haystack-is-empty%2C-the-needle-is-empty%2C-the-needle-is-longer-than-the-haystack%2C-or-the-start-offset-leaves-too-few-bytes), [BR-056](../../business-rules.md#br-056-a-header-is-stripped-only-when-the-signature-is-found-at-a-position-greater-than-zero))

## Context
- Namespace: `SAIF.Common.Extensions`
- Assembly/package: `SAIF.Framework.Common`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| PDF_FILE_HEADER | `public const string PDF_FILE_HEADER = "%PDF-"` | Well-known signature identifying a PDF file's leading bytes. |
| Search(this byte[] source, string signature, int startIndex, int endIndex) | `public static int Search(this byte[] source, string signature, int startIndex, int endIndex)` | Finds the index of a string signature within a byte range, or -1 if not found. ([BR-053](../../business-rules.md#br-053-a-string-search-pattern-over-a-binary-payload-is-encoded-as-ascii%2C-not-unicode), [BR-054](../../business-rules.md#br-054-a-byte-search-returns--1-when-the-haystack-is-empty%2C-the-needle-is-empty%2C-the-needle-is-longer-than-the-haystack%2C-or-the-start-offset-leaves-too-few-bytes)) |
| Search(this byte[] source, byte[] signature, int startIndex, int endIndex) | `public static int Search(this byte[] source, byte[] signature, int startIndex, int endIndex)` | Finds the index of a byte signature within a byte range, or -1 if not found. ([BR-054](../../business-rules.md#br-054-a-byte-search-returns--1-when-the-haystack-is-empty%2C-the-needle-is-empty%2C-the-needle-is-longer-than-the-haystack%2C-or-the-start-offset-leaves-too-few-bytes)) |
| StripHeader(this byte[] source, string signature, out bool found, int maxSearchLength) | `public static byte[] StripHeader(this byte[] source, string signature, out bool found, int maxSearchLength)` | Removes bytes preceding a located signature, reporting whether the signature was found. ([BR-055](../../business-rules.md#br-055-a-byte-search-may-be-capped), [BR-056](../../business-rules.md#br-056-a-header-is-stripped-only-when-the-signature-is-found-at-a-position-greater-than-zero)) |
| GetMD5Hash(this byte[] source) | `public static string GetMD5Hash(this byte[] source)` | Computes the MD5 hash of the byte array and renders it as a hex string. ([BR-057](../../business-rules.md#br-057-disposable-cryptographic-and-stream-resources-are-created-inside-using-blocks-so-they-are-released-deterministically)) |


## Sources
- `Common/SAIF.Common/Extensions/ByteExtensions.cs`
