\myheading{Swapping encryption and decryption procedures} By the way, this is quite important property of symmetric cryptography: encryption and decryption procedures can be swapped without loss of security: \begin{lstlisting}[style=custompy] # copypasted from https://pypi.org/project/pycrypto/ and reworked: from Crypto.Cipher import AES obj = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456') message = "Hello, world!!!!" # message's size must be multiple of 16 # decrypt "Hello, world" message: rubbish = obj.decrypt(message) print rubbish # rubbish printed # encrypt it back: obj2 = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456') plaintext_again=obj2.encrypt(rubbish) print plaintext_again # "Hello, world" printed \end{lstlisting} The author saw this in shareware checking license keys, etc, when a key is encrypted (yes) to get information from it. Perhaps, their key generator decrypted data when putting it to key file. Hopefully, they swapped functions just by mistake, but it worked, so they left it all as is. There is also a case of 3DES or Triple DES. Several variants are available, and the most popular encryption procedure (DES-EDE3) is: 1) encrypt with key1; 2) decrypt with key2; 3) encrypt with key3. The decryption procedure is inverted. This procedure is as secure as triple encryption using 3 keys (DES-EEE3).