Week 13 Cryptography
Week 13 Cryptography
Week 13 Cryptography
13
CRYPTOGRAPHY
ENCRYPTING AND DECRYPTING MESSAGES USING
CEASAR CIPHER AND MODULO OPERATOR
13
CRYPTOGRAPHY
https://www.youtube.com/watch?v=W-2eh66-IIk
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
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
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.
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.
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.
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 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
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.