0% found this document useful (0 votes)
14 views

Introduction to Codes and Ciphers 2

Uploaded by

S. Pathirathna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Introduction to Codes and Ciphers 2

Uploaded by

S. Pathirathna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

INTRODUCTION TO CODES

AND CIPHERS

Dr. Samitha Pathirathna


I.
INTRODUCTI
ON
 Opening Questions:
 - What comes to mind with
'codes' or 'secret messages'?
 - Who has used a simple
code, like a password?

Goals of the Lecture:


 - Understand codes vs.
ciphers.
 - Identify classical ciphers.
 - Recognize cryptography's
impact on modern security.
 Definitions:
 Code: Represents a message or phrase
with symbols or other words.
 Cipher: Alters each character based on a
II. CODES VS. rule or algorithm.
CIPHERS
 Examples:
 - Code: 'Operation Neptune' for D-Day.
 - Cipher: Caesar Cipher shifting letters.
MILITARY CODE
III. CLASSICAL CIPHERS - CAESAR
CIPHER
 Explanation: A shift cipher moving letters down the alphabet.
 Example: 'HELLO' shifted by 3 becomes 'KHOOR'.
III. CLASSICAL CIPHERS -
SUBSTITUTION CIPHER
 Explanation: Each letter is replaced by another letter or symbol.
 Example: 'CAB' becomes ‘PNO' using a fixed substitution.
III. CLASSICAL
CIPHERS -
TRANSPOSITION
CIPHER

 Retrangle
 Write : Row by Row
 Read : Column by
Column
 Key : Order of the
Column
III. CLASSICAL
CIPHERS -
TRANSPOSITION
CIPHER

 Retrangle
 Write : Row by Row
 Read : Column by
Column
 Key : Order of the
Column
III. CLASSICAL
CIPHERS -
TRANSPOSITION
CIPHER

 Retrangle
 Write : Row by Row
 Read : Column by
Column
 Key : Order of the
Column
III. CLASSICAL
CIPHERS -
TRANSPOSITION
CIPHER

 Retrangle
 Write : Row by Row
 Read : Column by
Column
 Key : Order of the
Column
III. CLASSICAL
CIPHERS -
TRANSPOSITION
CIPHER

 Retrangle
 Write : Row by Row
 Read : Column by
Column
 Key : Order of the
Column
III. CLASSICAL
CIPHERS -
TRANSPOSITION
CIPHER

 Retrangle
 Write : Row by Row
 Read : Column by
Column
 Key : Order of the
Column
III. CLASSICAL
CIPHERS -
TRANSPOSITION
CIPHER

 Retrangle
 Write : Row by Row
 Read : Column by
Column
 Key : Order of the
Column
III. CLASSICAL CIPHERS -
TRANSPOSITION CIPHER
 Explanation: Rearranges letters in a message without altering
them.
 Example: ‘MEET ME AT MIDNIGHT' rearranged as
EATITNIHMEXNETMGMEDT'.
III. CLASSICAL CIPHERS - VIGENÈRE
CIPHER
 Explanation: Uses a keyword to create varying shifts for each
letter.
 The Vigenère cipher uses a 26×26 table with A to Z as the row
heading and column heading
 This table is usually referred to as the Vigenère Table or Vigenère
Square.
 The first row of this table has the 26 English letters.
 Starting with the second row, each row has the letters shifted to
the left one position in a cyclic way.
 For example, when B is shifted to the first position on the second
row, the letter A moves to the end.
III. CLASSICAL CIPHERS - VIGENÈRE
CIPHER
III. CLASSICAL CIPHERS - VIGENÈRE
CIPHER
 In addition to the plaintext, the Vigenère cipher also requires a
keyword, which is repeated so that the total length is equal to that
of the plaintext.
 For example, suppose the plaintext is MICHIGAN TECHNOLOGICAL
UNIVERSITY and the keyword is HOUGHTON.
 Then, the keyword must be repeated as follows:
III. CLASSICAL CIPHERS - VIGENÈRE
CIPHER
 We follow the tradition by removing all spaces and punctuation,
converting all letters to upper case, and dividing the result into 5-
letter blocks.
 As a result, the above plaintext and keyword become the
following:

 To encrypt, pick a letter in the plaintext and its corresponding


letter in the keyword, use the keyword letter and the plaintext
letter as the row index and column index, respectively, and the
entry at the row-column intersection is the letter in the ciphertext.
III. CLASSICAL
CIPHERS -
VIGENÈRE CIPHER
 For example, the first
letter in the plaintext is
M and its
corresponding keyword
letter is H.
 This means that the
row of H and the
column of M are used,
and the entry T at the
intersection is the
encrypted result.
III. CLASSICAL
CIPHERS -
VIGENÈRE CIPHER
 Similarly, since the
letter N in MICHIGAN
corresponds to the
letter N in the keyword,
the entry at the
intersection of row N
and column N is A
which is the encrypted
letter in the ciphertext
III. CLASSICAL CIPHERS - VIGENÈRE
CIPHER
 Repeating this process until all plaintext letters are processed, the
ciphertext is TWWNPZOA ASWNUHZBNWWGS NBVCSLYPMM.
 The following has the plaintext, repeated keyword and ciphertext aligned
together.
III. CLASSICAL CIPHERS - VIGENÈRE
CIPHER
 . To decrypt, pick a letter in the ciphertext and its corresponding letter in
the keyword, use the keyword letter to find the corresponding row, and the
letter heading of the column that contains the ciphertext letter is the
needed plaintext letter.
 For example, to decrypt the first letter T in the ciphertext, we find the
corresponding letter H in the keyword.
 Then, the row of H is used to find the corresponding letter T and the
column that contains T provides the plaintext letter M.
 Consider the fifth letter P in the ciphertext.
 This letter corresponds to the keyword letter H and row H is used to find P.
 Since P is on column I, the corresponding plaintext letter is I.
III. CLASSICAL
CIPHERS -
VIGENÈRE CIPHER
 To decrypt, pick a letter in the ciphertext
and its corresponding letter in the
keyword, use the keyword letter to find
the corresponding row, and the letter
heading of the column that contains the
ciphertext letter is the needed plaintext
letter.
 For example, to decrypt the first letter T
in the ciphertext, we find the
corresponding letter H in the keyword.
 Then, the row of H is used to find the
corresponding letter T and the column
that contains T provides the plaintext
letter M.
 Consider the fifth letter P in the
ciphertext.
 This letter corresponds to the keyword
letter H and row H is used to find P.
 Since P is on column I, the
corresponding plaintext letter is I.
IV. THE EVOLUTION OF
CRYPTOGRAPHY - ENIGMA MACHINE
 Historical Background: Nazi Germany's Enigma created complex
codes.
 Significance: Breaking Enigma helped end WWII.
 Impact: Alan Turing's work influenced modern computing and
cryptography.
IV. ALAN TURING AND
CRYPTANALYSIS
 Biography: British mathematician and cryptanalyst.
 Contribution: Created the Bombe to crack Enigma.
 Impact: Laid foundations for computer science.
V. MODERN CRYPTOGRAPHY BASICS -
PUBLIC VS. PRIVATE KEY
 Public Key: Shared openly for encryption.
 Private Key: Secret for decryption.
 Example: Online banking encryption using public keys.
V. SYMMETRIC VS. ASYMMETRIC
ENCRYPTION
 Symmetric: Single key for encryption/decryption.
 Asymmetric: Public and private key pair.
 Real-life Use: SSL/TLS for secure web browsing.
VI. PRACTICAL EXERCISES AND
RECAP
 Activity: Groups encode messages with ciphers.
 Recap: Codes vs. ciphers, classical ciphers, significance of
cryptography.
 Q&A: Open the floor for questions and discussion.
STREAM CIPHERS AND
BLOCK CIPHERS
Principles, Examples, and Applications
 - Understand cryptographic principles:
Confusion and Diffusion.
 - Differentiate between Stream Ciphers
and Block Ciphers.
LEARNING  - Explore examples, modes, and real-world
OBJECTIVES applications.
 - Analyze advantages and limitations of
both cipher types.
 - Perform practical examples.
CORE  - Confusion: Hides the relationship between key and
ciphertext using substitution.
PRINCIPLES:
 - Diffusion: Spreads plaintext influence across
CONFUSION ciphertext using transposition.
AND  - Examples include AES S-box (confusion) and DES
DIFFUSION permutations (diffusion).
VISUALIZING CONFUSION AND
DIFFUSION

- Confusion Example: - Diffusion Example:


HELLO ? IFMMP HELLO ? OELHL
(Substitution). (Permutation).
VISUALIZING CONFUSION AND
DIFFUSION
- Encrypts data one bit
or byte at a time.

- Suitable for real-time


STREAM
encryption, e.g., video CIPHERS
calls.

- Uses pseudorandom
key streams for
encryption.
HOW STREAM CIPHERS WORK

1. Generate a 2. XOR the plaintext with 3. Decrypt ciphertext using


pseudorandom key stream the key stream to produce the same key stream.
using a secret key. ciphertext.
EXAMPLES OF STREAM CIPHERS

- RC4: Used in WEP, early - ChaCha20: Modern, secure - XOR Example: Plaintext
TLS (vulnerable to key stream cipher (used in TLS). 1011 XOR Key Stream 1100
reuse). = Ciphertext 0111.
BLOCK CIPHERS

 - Encrypts data in fixed-size blocks, e.g.,


128 bits for AES.
 - Processes chunks of data; padding is
added if needed.
 - Examples: AES (widely used), DES
(outdated).
HOW BLOCK CIPHERS WORK

1. DIVIDE PLAINTEXT INTO 2. ENCRYPT EACH BLOCK 3. COMBINE ENCRYPTED


FIXED-SIZE BLOCKS. USING THE SAME KEY. BLOCKS FOR CIPHERTEXT
OUTPUT.
REAL-WORLD APPLICATIONS

- Block Ciphers:
- Stream Ciphers: Secure
Real-time data, messaging (e.g.,
video streaming, WhatsApp uses
IoT encryption. AES), file
encryption.
SUMMARY

- Confusion and - Stream Ciphers: - Block Ciphers: - Examples: RC4,


Diffusion enhance Bit-level encryption, Secure block-level AES, ChaCha20.
cryptographic suitable for real-time encryption, suitable
strength. data. for static data.

You might also like