VernamVeil Logo

API Reference:

  • Byte Search
    • find()
    • find_all()
  • Deniability Utilities
  • Fx Utilities
  • Hash Utilities
  • VernamVeil Class

Guides & Implementation Notes:

  • Getting Started and Concepts
  • C Extension Build and Usage
VernamVeil
  • Byte Search
  • Edit on GitHub

Byte Search

vernamveil.find(haystack, needle, start=0, end=None)

Finds the first occurrence of needle in haystack[start:end] using the fast C byte search, or Python fallback.

Return type:

int

Parameters:
  • haystack (bytes or bytearray or memoryview) – The bytes object to search within.

  • needle (bytes or bytearray or memoryview) – The bytes object to search for.

  • start (int) – The starting index to search from. Defaults to 0.

  • end (int, optional) – The ending index (exclusive) to search to. Defaults to None (end of haystack).

Returns:

The 0-based starting index of the first occurrence, or -1 if not found.

Return type:

int

vernamveil.find_all(haystack, needle)

Finds all occurrences of needle in haystack using a fast byte search algorithm.

Return type:

list[int]

Parameters:
  • haystack (bytes or bytearray or memoryview) – The bytes object to search within.

  • needle (bytes or bytearray or memoryview) – The bytes object to search for.

Returns:

A list of 0-based starting indices of all occurrences. Returns an empty list if

no occurrences are found or if the pattern is empty or longer than the text.

Return type:

list[int]

Previous Next

© Copyright 2025, Vasilis Vryniotis.

Built with Sphinx using a theme provided by Read the Docs.