How amanthink/xor_cipher works
This is a single-file C++ command-line toolkit for CTF cipher analysis. The user supplies hex data and selects an attack, transform, ChaCha20 operation, or chained pipeline; the selected mode processes the bytes and prints results. Repeating-key XOR cracking estimates a key length before solving byte positions, while chain mode applies operations in order. All implementation paths below are main.cpp. The excerpts omit some handlers and helper bodies, so those links rely on README-described behavior; uncertain internal wiring is left out.
Main entry points: main.cpp Mode dispatch
Components 15
CLI and encoding
- Mode dispatch
main.cpp - Hex conversion
main.cpp - ASCII to hex
main.cpp
Cipher analysis
- Single-byte XOR
main.cpp - English scoring
main.cpp - Repeating-key crack
main.cpp - Key-size estimate
main.cpp
Transforms and ciphers
- Nibble swap
main.cpp - Bit rotations
main.cpp - ChaCha20 mode
main.cpp - Keystream XOR
main.cpp - ChaCha20 block
main.cpp - Chain mode
main.cpp - Fixed-byte XOR
main.cpp
Other components
- CLI user
Connections 19
- CLI user → Mode dispatch: selects mode
- Mode dispatch → Hex conversion: decodes input
- Mode dispatch → ASCII to hex: converts string
- Mode dispatch → Single-byte XOR: dispatches
- Mode dispatch → Repeating-key crack: dispatches
- Mode dispatch → Nibble swap: dispatches
- Mode dispatch → Bit rotations: dispatches
- Mode dispatch → ChaCha20 mode: dispatches
- Mode dispatch → Chain mode: dispatches
- Single-byte XOR → English scoring: scores candidates
- Repeating-key crack → Key-size estimate: estimates key size
- Repeating-key crack → Single-byte XOR: cracks key blocks
- Bit rotations → English scoring: scores candidates
- ChaCha20 mode → Hex conversion: parses key and nonce
- ChaCha20 mode → Keystream XOR: encrypts or decrypts
- Keystream XOR → ChaCha20 block: generates blocks
- Chain mode → Fixed-byte XOR: applies XOR
- Chain mode → Nibble swap: applies nibble swap
- Chain mode → Bit rotations: applies rotations