Monoalphabetic Substitution Decipherer

From UBC Wiki

authors: Mehrsa Baghaei, Yichen Lu

What is the problem?

The challenge is to implement a monoalphabetic substitution ciphering and deciphering program in Prolog. This involves replacing each letter in a plaintext message with a corresponding letter in the ciphertext using a fixed substitution key. The goal is to automatically decrypt and encrypt messages with this cipher with the key phrase or keyword. The program aims for simplicity and ease of use, focusing on clear, step-by-step processes for both encryption and decryption tasks. This simplicity will be achieved through:

  • Clear User Interface: Implementing an intuitive user interface that guides users through the encryption and decryption process with minimal input required.
  • Straightforward Input: Allowing users to input the plaintext message and necessary parameters (keyword for encryption, mnemonic phrase for decryption) in a straightforward manner.
  • Minimal Complexity: Designing the program logic to be concise and easy to understand, emphasizing functional programming principles to maintain clarity in implementation.

What is the something extra?

  • Ciphering and Deciphering: The program should facilitate both the encryption (ciphering) and decryption (deciphering) of messages using a monoalphabetic substitution method.
  • Keyword Encryption: For encryption, a user-provided keyword will determine the substitution mapping of letters from the plaintext to the ciphertext. This keyword is used to generate a unique substitution alphabet and vice versa. making the process that can take time to map out and figure out be done in seconds.
  • Mnemonic Phrase Decryption: Decryption will be accomplished using a mnemonic phrase, which acts as the key to reverse the encryption process. This phrase consists of a set of random words (12 or 24 words) presented in a specific order.
  • Caesar Cipher Decryption: The decryption process reverses the encryption shift. It shifts each letter in the ciphertext back up the alphabet by the same number of places. If the ciphertext was encrypted with a shift of 3, the decryption will shift each letter back by 3 places, thus restoring the original plaintext.
  • Message Format: All messages (plaintext and ciphertext) will be in lowercase letters to simplify the ciphering and deciphering process

What did we learn from doing this?

  • Understanding Monoalphabetic Substitution: Gain insights into the fundamentals of monoalphabetic substitution ciphers
  • Functional Programming for Cryptography: Apply functional programming concepts in Prolog to implement cryptographic algorithms effectively, leveraging features like pattern matching and list manipulation.
  • Sorting Lists in Prolog: Explore Prolog's list manipulation capabilities to implement sorting algorithms, which are essential for tasks like keyword-based letter substitution in monoalphabetic ciphers.

Links to code etc.

github