src.ch05 package

Submodules

src.ch05.p1_encode_null module

Encode a message in a list using a null cipher.

src.ch05.p1_encode_null.encode_null(message: str, word_list: list) → list[source]

Encode plaintext message with null cipher.

Embed message in a list of words using word_list. Use second letter in first word of cipherlist, then third letter in second word of cipherlist, and repeat until message is embedded in cipherlist.

Parameters
  • message (str) – Message to encrypt with null cipher. Spaces and punctuation are okay, but will be removed. Uppercase converted to lowercase.

  • word_list (list) – List of words to build cipherlist. The more the merrier.

Returns

List of words with message embedded as described. Context is not provided.

Raises

ValueError – if the list of names doesn’t have a name with the needed letter.

src.ch05.p1_encode_null.main()[source]

Demonstrate null cipher encoder.

Encode a message in a list of last names. First last name in list isn’t used and some unused last names are added near the beginning of the list.

Tip

The website bestwordlist.com helped with the missing names.

src.ch05.p2_decode_null module

Decode plaintext message from null cipher.

src.ch05.p2_decode_null.decode_null(interval: int, ciphertext: str) → str[source]

Decode message from null cipher.

For every word specified by interval in ciphertext, generate a string using each interval letter.

Parameters
  • interval (int) – nth letter of every nth word to form a string.

  • ciphertext (str) – String with null cipher encoded message. Spaces and punctuation are okay, but will be removed. Uppercase converted to lowercase.

Returns

String containing nth letter of every nth word in ciphertext.

Example

>>> from src.ch05.p2_decode_null import decode_null
>>> ciphertext = 'national aeronautics space administration'
>>> decode_null(1, ciphertext)
'nasa'
src.ch05.p2_decode_null.main()[source]

Demonstrate null cipher decoder.

Tip

The website bestwordlist.com helped a metric ton.

Module contents

Chapter 5.