Everything else in a cipher — XOR, shift, permute — is linear, and linear ciphers fall to linear algebra. The S-box (substitution box) is the one nonlinear part: a fixed table that maps each small input to a scrambled output, chosen so that S(a)⊕S(b) ≠ S(a⊕b). It is Shannon’s confusion made concrete — the step that makes the relationship between key and ciphertext too tangled to solve.
A 4-bit S-box is a permutation of 0…15. Apply it, and check its nonlinearity: S(1)⊕S(2) is not S(1⊕2) — the property a linear map can never have: live demo
“S-boxes are just random lookup tables.” — no. They are carefully engineered for high nonlinearity and resistance to differential/linear cryptanalysis; the DES S-boxes were tuned (by IBM, with NSA input) against attacks not public until 1990, and the AES S-box is the multiplicative inverse in GF(2⁸) plus an affine map — algebra, not chance. cited
Confusion is not obscurity: the AES S-box has a one-line algebraic definition, yet its input/output bits are related by high-degree Boolean functions — transparent to build, opaque to attack. Shannon 1949 / DES 1977
On the canonical compiler the S-box is an array lookup, and its defining nonlinearity holds: