External Exam Download Resources Web Applications Games Recycle Bin

Bacon Cipher

baconcipher.py

baconian = {
  'a':'aaaaa',
  'b':'aaaab',
  'c':'aaaba',
  'd':'aaabb',
  'e':'aabaa',
  'f':'aabab',
  'g':'aabba',
  'h':'aabbb',
  'i':'abaaa',
  'j':'abaab', 
  'k':'ababa',
  'l':'ababb',
  'm':'abbaa',
  'n':'abbab',
  'o':'abbba', 
  'p':'abbbb',
  'q':'baaaa',
  'r':'baaab',
  's':'baaba',
  't':'baabb', 
  'u':'babaa',
  'v':'babab',
  'w':'babba',
  'x':'babbb',
  'y':'bbaaa',
  'z':'bbaab'
} 

plain_text = "hi"
sentence_to_hide_with = "darthvader"

# Task 1: automate the creation of this bacon_text and cipher_text:
bacon_text = "aabbb" + "abaaa" #groups of 5 letters per letter
cipher_text = "daRTHvAder" #lowercase a, UPPERCASE B


# Task 2: develop a method to decrypt the resulting Baconian cipher_text


# Task 3: allow the plain_text to be input at run-time.
# wrap or truncate the sentence_to_hide_with if it is longer or shorter.