CrackingCodes.Ch18 package

Submodules

CrackingCodes.Ch18.PracticeQuestions module

Chapter 18 Practice Questions

Answers Chapter 18 Practice Questions via Python code.

CrackingCodes.Ch18.PracticeQuestions.main()[source]

CrackingCodes.Ch18.stringTest module

Create string test

Timing string concatenation vs list appending to make a string.

Note

  • Prints time to make a 10000 character string 10000 times as seconds since the Unix epoch.
CrackingCodes.Ch18.stringTest.main()[source]

CrackingCodes.Ch18.vigenereCipher module

Vigenère Cipher (Polyalphabetic Substitution Cipher)

Provides functions that implement a Vigenère cipher.

CrackingCodes.Ch18.vigenereCipher.LETTERS

String containing uppercase latin letters.

Type:str

Example

>>> import pythontutorials.books.CrackingCodes.Ch18.vigenereCipher as vigenereCipher
>>> key = 'supercalifragilisticexpialidocious'
>>> message = 'A soul shines brightest when it stands alongside the darkness. -Anon, probably'
>>> vigenereCipher.encryptMessage(key, message)
'S mdyc uhtvjj bxqrplxav aetv ie awoplg udghvwzfe epj uaxsymkl. -Ipsk, ezomieza'
CrackingCodes.Ch18.vigenereCipher.decryptMessage(key: str, message: str) → str[source]

Vigenère cipher decryption

Wrapper function that decrypts given message with given key using the Vigenère cipher.

Parameters:
  • key – String decryption key to encrypt with Vigenère cipher.
  • message – Message string to decrypt.
Returns:

Decrypted message string.

CrackingCodes.Ch18.vigenereCipher.encryptMessage(key: str, message: str) → str[source]

Vigenère cipher encryption

Wrapper function that encrypts given message with given key using the Vigenère cipher.

Parameters:
  • key – String encryption key to encrypt with Vigenère cipher.
  • message – Message string to encrypt.
Returns:

Encrypted message string.

CrackingCodes.Ch18.vigenereCipher.main()[source]
CrackingCodes.Ch18.vigenereCipher.translateMessage(key: str, message: str, mode: str) → str[source]

Vigenère cipher

Implements a Vigenère cipher that can encrypt or decrypt messages depending on the given mode.

Parameters:
  • key – String containing key used to decrypt/encrypt messages.
  • message – String containing message to decrypt/encrypt.
  • mode – String specifying whether to ‘encrypt’ or ‘decrypt’.
Returns:

Encrypted or decrypted message.

Module contents