Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Week

13

CRYPTOGRAPHY
ENCRYPTING AND DECRYPTING MESSAGES USING
CEASAR CIPHER AND MODULO OPERATOR

NORA G. YULO, MATM 111 Instructor


Week

13

CRYPTOGRAPHY
https://www.youtube.com/watch?v=W-2eh66-IIk

Nora G. Yulo , MATM 111 Instructor


Week

CRYPTOGRAPHY 13
The word CRYPTOGRAPHY originated from two greek words,
“krypto” which means hidden and “graphene” which means
writing. It is the making or breaking of secret codes. It uses two
processes namely:
https://www.youtube.com/watch?v=W-2eh66-IIk
1.) ENCRYPTION – the process of transforming plain text into
code form using a certain algorithm.
Example: Math is fun (plain text) ----- original message
PDWK LV IXQ (coded form) ----- Cipher text

2.) DECRYPTION – the process of converting back the coded


message into plain text.
Week

CRYPTOGRAPHY 13
*KEY – refers to the strings of information that is used to reveal
the encrypted message into readable form.

Methods of Cryptography:
1.) Shift Cipher (Ceasar Cipher)
2.) Using a Modulo Operator

SHIFT CIPHER – the simple type of substitution cipher. It uses


shift informing the key of cryptography.
Example 1: Using the key of shift of 3 to the right, encrypt the
word “CRYPTOGRAPHY.”
Week

CRYPTOGRAPHY 13
Example 1: Using the key of shift of 3 to the right, encrypt the word
“CRYPTOGRAPHY.”
Solutions:
Step 1: Write the letters of the English alphabet.
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Step 2: Make 3 shifts from the given letter going to the right.

ABCDEFGHIJKLMNOPQRSTUVWXYZ

This means that after shifting C thrice to the right, its equivalent is F.
Step 3: Form the encrypted message. CRYPTOGRAPHY – FUBSWRJUDSKB
Week

CRYPTOGRAPHY
Example 2: Decrypt the cipher text, “BJY DN BJJY”, using the key of 5
13
shifts to the left.
Solutions:
Step 1: Write the letters of the English alphabet.
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Step 2: Make 5 shifts from the given letter going to the right (opposite
of the given direction when the process involved is decryption).

ABCDEFGHIJKLMNOPQRSTUVWXYZ
This means that after shifting B five times to the right (opposite direction), its equivalent is G.

Step 3: Form the encrypted message.


“BJY DN BJJY” – “GOD IS GOOD”
Using the key
AB C D E F G H I J K L M N O P Q R S T U V W X Y Z
shift of 7 to
the LEFT.
ENCRYPT
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

1. QNKJ 2. YnpytpJnxy 3. bUTTERFLY


LTJX Encrypt shift 5 to
Decrypt shift 5 to
TS the right the right

Decrypt shift 5 to the


right

1. ____ 2. __________ 3. __________


____
Decrypt shift 5 to
__ the right

Decrypt shift 5 to the Encrypt shift 5 to the


right right
Week

CRYPTOGRAPHY 13
USING MODULO OPERATOR – the sender of the message uses the
key K to encrypt and to decrypt the secret message. The key K
may have any integer value from 0 to 25 and this will be shared to
the person/s who will be receiving the secret message.

Steps in Encrypting Message:


Step 1: Express the letters of the alphabet into an integer from 0
to 25, that matches its order, for example, A=0, B=1, C=2, . . .,
then label them as C.
Step 2: Calculate Y = (C + K)mod26, for every letter of message.
Step 3: Convert the number Y into a letter following the order of
the letter of the alphabet.
Week

CRYPTOGRAPHY 13
Example 1: Encrypt the message “MMW is fun to learn.” Let k = 5.
Following the steps, here’s the solution:
Step 1:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Step 2: M M W I S F U N T O L E A R N
12 12 22 8 18 5 20 13 19 14 11 4 0 17 13 C
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 +K
17 17 27 13 23 10 25 18 24 19 16 9 5 22 18 C+K

Step 3: Since 27 exceeded 25, apply modulo operator to find its equivalent.
That will be Y = 27mod26 which is equal to 1. Converting every Y into a
letter in the english alphabet we have RRB NX KZS YT QJFWS.
Week

CRYPTOGRAPHY
Example 2: Encrypt the message “Maybe this time.” Let k = 4.
13
Following the steps, here’s the solution:
Step 1: ABCDEFGHIJKLMNOPQRSTUVWXYZ
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Step 2:

C
+K
C+K

Step 3: Since 27 exceeded 25, apply modulo operator to find its equivalent.
That will be Y = 27mod26 which is equal to 1. Converting every Y into a letter
Week

CRYPTOGRAPHY 13
Steps in Decrypting Message:
Step 1: Express the letters of the alphabet into an integer from 0
to 25, that matches its order, for example, A=0, B=1, C=2, . . .,
then label them as Y.
Step 2: Calculate C = (Y – K)mod26, for every letter of the
decrypted message.
Step 3: Convert the number C into a letter following the order of
the letter of the alphabet.

Example 2: Decrypt the message “RRB NX KZS YT QJFWS”.


Let k = 5.
Week

CRYPTOGRAPHY 13
Example 3: Decrypt the message “RRB NX KZS YT QJFWS”. Let k = 5.
Here’s the solution:
Step 1: ABCDEFGHIJKLMNOPQRSTUVWXYZ
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Step 2: R R B N X K Z S Y T Q J F W S
17 17 1 13 23 10 25 18 24 19 16 9 5 22 18 Y
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 – K
12 12 - 4 8 18 5 20 13 19 14 11 4 0 17 13 Y–K

Step 3: Determine the equivalent of –4 (by shifting 4 units to the left or


backward). –4 corresponds to W. Converting every C into a letter in the
English alphabet we have ”MMW IS FUN TO LEARN.”
CRYPTOGRAPHY
Week
Example 4: Decrypt the message “ ZUNCGU ”. Let k = 20.
Here’s the solution: 13
Step 1: ABCDEFGHIJKLMNOPQRSTUVWXYZ
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Step 2: Y
– K
Y–K

Step 3: Determine the equivalent of –20 (by shifting 4 units to the left or
backward). –4 corresponds to W. Converting every C into a letter in the
English alphabet we have ” .”
Try CRYPTOGRAPHY Week

this
Example 5: Decrypt the message “Q Twdm JBA”. Let k = 8.
13
Here’s the solution:
Step 1: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Step 2: Y
– K
Y–K

Step 3:We have ” .”


Week

13
End of session
You may ask your questions
now. Do you have any? If
there are no more questions,
prepare for your offline task.

You might also like