Lecture 12 (Tychonievich) - Encryption

Lecture Date: Monday 9 February

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

Strings:

  • s.charAt(index) -> a char at that index (starting at 0)
  • s.length() -> how many chars there are
  • s += "w" -> add a w to the end of s

Assume s is a String. What is the index of the last char in s?

Questions:

  • Can I post all of the code?
    Yes, I will after class (probably around 1:15pm)

  • How do I change all variables at once
    Shft+Alt+R

  • Why single quotes in if statement
    to be char values, not variables or Strings

  • What about words that have op?

    stopop
    [s]topop => s
    s[t]opop => st
    st[opo]p => sto
    stopo[p] => stop

Ceasar adds 3 to each letter ((char)('a' + 3) yields 'd'). 3 is the “key”.

Vignere adds a different digit to each letter; key is a several-digit number. For example, with the key 1602, “programming” becomes

 "pogramming"
+ 1602160216
—————————————
 "qugtbsmkom"

From lecture:

Code:

Audio: