Basic Ciphers and Cryptographic Algorithms

SST Computer Club

September 6, 2018

Caesar Cipher

  • Named after Julius Caesar
    • Used it for sending message in secret
  • Offset each letter by a given number
  • Symmetric:
    • You can get the plaintext from the ciphertext just as easily as getting the ciphertext from the plaintext
  • Fairly easy to decipher:
    • Just go through all 26 different shifts, check if the output is readable

Caesar Cipher Diagrams

Caesar Cipher Example

  • Plaintext: SECRET

  • Shift: +13

  • Ciphertext: SECRET => FRPERG

Modulus

  • For a positive number, it is the remainder after you divide
  • Can be represented as a clock
    • Each time you go around, it starts over
  • Commonly represented by % in various programming languages
  • Examples:
    • 5 mod 2 = 1
    • 0 mod 3 = 0
    • 10 % 4 = 2
    • 25 % 10 = 5

ASCII Table

Caesar Function in Python

Vigenère Cipher

  • Leon Battista Alberti in 1467 Italy
    • Artist, Author, Architect, Poet, Cryptographer
  • Using multiple Caesar Ciphers and a Key
  • The key determines what shift to use for a certain character
  • Use a Vigenère Square (tabula recta) to line up alphabets and encode just like a Caesar Cipher
    • Use the same square to decode

Vigenère Square

Vigenère Encoding Example

  • Plaintext: SECRET

  • Key: NICE => NICENI

  • Shifts: NICENI => (13, 8, 2, 4, 13, 8)

  • Ciphertext: SECRET => FMEVRB

Frequency Analysis

  • In any language, some letters are much more frequently used than others
  • We can use this to are advantage and help decipher messages that were encrypted using a substitution method
  • Different languages have different letter frequencies
    • This is why scrabble letters have different points in other languages

English Letter Frequency

Applications:

  • Most online services need to store passwords
    • Storing them in plain-text would be a violation of security
    • They use asymmetric encryption to hash the password and get a ciphertext that will be stored in their database
    • A slight change in the input (password) will result in an entirely different hash
    • When you sign into that service, it will hash the password you put it in and compare it with the store hash
      • If they match you can sign in
  • The S (Secure) in HTTPS://
    • A website and your browser use various cryptographic methods to
      • Verify that the website is who it says it is
      • Make sure that only the website and you can decipher the data that is sent back and forth

Image Sources