Keyed substitution
AES can be explained in a single sentence: it is a keyed permutation (keyed permutation). That is, for each key it maps the set of 16-byte blocks onto itself in a one-to-one (bijective) manner. Being one-to-one is very important: if two different plaintexts produced the same ciphertext, decryption would be fundamentally impossible.
Now we will see this idea in its simplest form. Below is given a random permutation (table) of the numbers 0..255: jadval[i] — indicates what the byte i is replaced with. The table is in the attached jadval.txt file, the number in the left column is the row's starting index.
The flag was substituted byte-by-byte using this table. Recover it:
9af0b974d97f43f096cd75a8ab512650512675ab5111ab0fa25026a3260fa275
2f26f496a80f355cc5e2
Creating the reverse table takes a few lines of code: inv = [0]*256, then for each i, inv[perm[i]] = i.