# `legacy/` — The original single-file implementation This directory preserves the **original single-file script** for three purposes: 1. **Interoperability testing.** `tests/test_legacy_interop.py` loads `chaoscrypt_legacy.py` and proves that data moves freely between the two implementations in both directions. 2. **Historical reference.** The original form makes it easy to compare behaviour before and after the restructure. 3. **Teaching.** A single file with no packaging concerns is often the clearer way to read an algorithm end to end. ## Contents | File | Description | |---|---| | `chaoscrypt_legacy.py` | The original `chaoscrypt.py`, **unmodified** | | `encryption.key` | Sample key file used by the original script (test data only) | ## Important - **Do not use these scripts.** New code should use the `chaoscrypt` package. - This directory is **not** included in the wheel. It ships in the source distribution only, for the tests above. - The two implementations are **bit-for-bit equivalent** and share an identical key file format, so key files and ciphertexts are freely interchangeable between them. ## Verifying interoperability ```bash # From the repository root python -m pytest chaoscrypt/tests/test_legacy_interop.py -v ``` ## Limitations of the original script The original implementation worked, but its structure made it unsuitable as a library. The restructure addressed the following: 1. **Algorithm and presentation were coupled.** `print` and `input` calls were interleaved with the cryptographic logic, so the module could not be imported and used programmatically. 2. **Failures returned strings rather than raising.** A failed decryption returned a sentinel string such as `"Decryption failed"`, which callers had to compare against a literal. Real exceptions make failure impossible to overlook. 3. **Key loading state could become inconsistent.** A wrong key file password printed a message but did not always leave the object in a well-defined state. 4. **No command line interface.** Every operation required an interactive session, so the script could not be used in automation. 5. **No binary or file-level API.** Only text could be encrypted directly. 6. **No unified error type.** Each failure path reported itself differently. 7. **Non-hexadecimal input was accepted silently.** A corrupt ciphertext would decrypt into garbage and be indistinguishable from success.