Skip to content

fix: assign result of .upper() in _next_letter and remove unused imports#1

Merged
MaxAnderson95 merged 2 commits intomainfrom
fix/bugs-and-unused-imports
Mar 20, 2026
Merged

fix: assign result of .upper() in _next_letter and remove unused imports#1
MaxAnderson95 merged 2 commits intomainfrom
fix/bugs-and-unused-imports

Conversation

@MaxAnderson95
Copy link
Owner

Summary

  • Fixed a bug in EnigmaMachine._next_letter() where letter.upper() was called but the result was never assigned back, making it a no-op. Lowercase input (e.g. 'z') would produce '{' instead of 'A'.
  • Removed unused import from math import e in rotor.py.
  • Removed unused import import re in reflector.py.
  • Added 43 property-based fuzz tests using hypothesis that verify core cryptographic invariants: rotor bijectivity, reflector involution, plugboard symmetry, and the machine's reciprocal encryption property across thousands of randomized configurations.

_next_letter discarded the return value of str.upper(), which would
produce incorrect results for lowercase input. Also removed unused
imports (math.e in rotor.py, re in reflector.py).
Adds 43 fuzz tests covering rotor bijectivity, reflector involution,
plugboard invariants, machine reciprocal encryption, and edge cases.
@MaxAnderson95 MaxAnderson95 merged commit 4575399 into main Mar 20, 2026
1 check passed
@MaxAnderson95 MaxAnderson95 deleted the fix/bugs-and-unused-imports branch March 20, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant