|
EnigmaMachineCore 0.1.0
A modular Enigma Machine simulation in C++20
|
This document defines the official public interface of the EnigmaCore library. Following the "Strict Facade" architectural pattern, the library exposes only the minimal set of interfaces required to configure, execute, and monitor the Enigma engine.
To ensure long-term binary stability (ABI) and security, EnigmaCore enforces a clean separation between the Public Surface and Internal Mechanics.
Rotor, PlugBoard, RotorBox) are hidden using forward declarations and the Pimpl (Pointer to Implementation) pattern.ENIGMACORE_EXPORT are visible in the shared library's export table.AlphabetIndex) instead of raw primitives to ensure range validation and architectural clarity.IAssetProvider, IEnigmaObserver, ILogger) allow consumers to extend the library's behavior without accessing its private state.This header defines the basic types used across the library to ensure type safety and platform independence.
The EnigmaMachine class is the primary entry point for all encryption operations.
EnigmaMachine(): Initializes a standard machine with default rotors (I, II, III). If the library is installed, it automatically attempts to find these assets in the system's share/ directory.EnigmaMachine(string_view fileName, string_view assetPath): Standard file-based initialization.EnigmaMachine(IAssetProvider& provider, string_view fileName, string_view assetPath): Dependency-injected initialization for custom environments.AlphabetIndex keyTransform(AlphabetIndex input): Transforms a single character index (0 to TRANSFORMER_SIZE - 1). This method handles the internal rotor stepping, multi-stage transformation, and observer notifications.void processBuffer(std::span<AlphabetIndex> buffer): Processes a contiguous block of characters in-place. This is the preferred method for performance-critical batch processing.void setLogger(ILogger* logger): Attaches a custom logger implementation to the engine.void registerObserver(IEnigmaObserver*): Attaches a listener to monitor internal events.void removeObserver(IEnigmaObserver*): Detaches a listener.Consumers implement this interface to react to state changes within the machine.
This interface decouples the engine from the physical filesystem, enabling support for WebAssembly (Memory-based) and Embedded (Flash-based) targets.