Date

Lecture Date: Friday, September 30

What is encryption?

  • Change the form of data to conceal the meaning
  • hidden text

Why do we care? Why in CS?

  • Data Security
  • Do not want people to snoop on us
  • Do want to know we are talking to a particular person

Vocabulary:

  • plaintext - what we are hiding
  • ciphertext - what it looks like after we hide it
  • encrypt - go from plaintext to ciphertext
  • decrypt - go from ciphertext to plaintext
  • cipher - a technique for encrypting/decrypting
  • key - which variant of the cipher we are using

strs:

  • s[index] -> a character at that index (starting at 0)
  • len(s) -> how many chars there are
  • s += "w" -> add a w to the end of s

Assume s is a str. What is the index of the last character in s?

Ciphers to discuss:

  • Caesar
  • Vignere
  • Route
  • Scytale
  • Line-Word-Letter

Some example code:

plaintext = input("What should we turn into oppish?: ")
plaintext = plaintext.lower()
vowels = ['a', 'e', 'i', 'o', 'u']
ciphertext = ""
for letter in plaintext:
    if letter in vowels:
        ciphertext += "op"

    ciphertext += letter

print(ciphertext)

index = 0
decrypted = ""

while index < len(ciphertext):
    if ciphertext[index] == 'o' and ciphertext[index + 1] == 'p':
        decrypted += ciphertext[index + 2]
        index += 3
    else:
        decrypted += ciphertext[index]
        index += 1

print(decrypted)