Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Laboratory work 12

Security instructions for working with computers:


Before turning on the computer, you must examine the personal computer on integrity of the computer case, that wires don't disturb work and movement;
Optimum distance of eyes up to the monitor during working time (60-70 cm.);
It is strictly forbidden:
To touch to wires, forks, sockets, move of the equipment during working time;
To work at the computer wet hands or in wet clothes;
To put any subjects or to spill liquids on the computer or the keyboard;
At detection of defects in operation of the computer, a smell of burning, you have to stop work, switch off the computer and tell to the teacher.

Using Excel to do shift and affine ciphers


Caesar Cipher / Rot-13
The classic version uses the capital letters
A-Z, but, in principle, an arbitrary alphabet can be used. The first
step is to write the alphabet down two times.

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
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
Now, the bottom alphabet is shifted by an arbitrary number of positions. The number of positions is the
key-value. Shifting the bottom alphabet 3 positions to the right yields the following result:

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
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
The letter A becomes the letter D. B is replaced by E and C replaced by F, etc. The word "example" would be encoded by:
"hadpsoh".

- A B C D
1 [first letter of text] =КОДСИМВ(A1)-65 =ОСТАТ(B1+3, 26) = СИМВОЛ(C1 + 65)
[second letter of the text,
[copy and paste the above into [copy and paste the above into [copy and paste the above into
2 continuing into the column
the column below] the column below] the column below]
below]
You should check to see that this is working before going on. To shift by another amount, change the number 3 in cell C1 to that
number, and copy and paste into the column below.

More sophisticated shift cipher


What's above is a basic spreadsheet. If you're tired of copying and pasting, do the following:
 Change the entry in cell C1 as below
 Put the number you want to shift by in cell F1. Illustrated is a shift by 3. (The dollar signs make the reference absolute
rather than relative.)
 (Do nothing in cells E1, E2 and F2.)
- A B C D EF
1[first letter of text] = КОДСИМВ (A1)-65 = ОСТАТ (B1+$F$1, 26) = СИМВОЛ (C1 + 65) - 3
[second letter of the text, [copy and paste the above into [copy and paste the above into[copy and paste the above
2 - -
continuing into the column below] the column below] the column below] into the column below]
It's a good idea to test out what you've written before you use it for other things. You can do this by shifting by 0. This should leave
the text unchanged.

Affine ciphers
 Change the entry in cell C1 as below
 Put the number to multiply by in cell E1, and the number to shift by in cell F1 (as before). Illustrated is multiplying by 2 and
shifting by 3.
 (Do nothing in cells E2 and F2.)
- A B C D EF
1[first letter of text] = КОДСИМВ (A1)-65 = ОСТАТ (B1*$E$1+$F$1, 26) = СИМВОЛ (C1 + 65) 23
[second letter of the text,
[copy and paste the above into [copy and paste the above into [copy and paste the above
2 continuing into the column - -
the column below] the column below] into the column below]
below]
Once again it's a good idea to test out what you've written before you use it for other things. Try the following
 Multiply by 1 and shift by 0. This should leave the text unchanged.
 Multiply by 0. Is the effect as expected?

Vigenère Cipher
A key of arbitrary length has to be chosen. The key, and the text that will be encoded, have to use characters from the same
alphabet. For demonstration purposes, we will use the capital letters A-Z only.
As an example, the sentence “THIS IS A SECRET TEXT” will now be decoded with the key "KEY". First, we write the key
beneath the plaintext and repeat it until the whole length of the plaintext is covered…
T H I S I S A S E C R E T T E X T
K E Y K E Y K E Y K E Y K E Y K E
Now we are using the Caesar cipher. The first character occurring in the plaintext, T is encoded by the character corresponding to
the first character of the key, K. This means that the original mapping of the Caesar cipher is shifted by the key 'K' to the left. The
'K' is the eleventh character in the alphabet, so we have to shift the mapping 10 positions to the left, which reads the following:

Plaintext alphabet
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
K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
Ciphertext alphabet

A would thus be mapped to K, B to L, C to M and therefore the T (from our mesasge) to the D. Next, the second character in the
plaintext, I, will be mapped by the Caesar cipher with a character corresponding to the second character in the key E.
E is the fifth character in the alphabet, so we have to shift the original mapping by 4 positions to the left:

Plaintext alphabet
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
E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
Ciphertext alphabet

Therefore, the H will be mapped to the L. The encoded text so far is DL. If we encode the whole message with the same procedure
we will get the encoded text: "DLGC MQ K WCMVCD XCHX ".

The Vigenère cipher can be considered as a consecutive application of different Caesar ciphers. One has to simply look up the line
for the respective Caesar cipher to find the encoded text character.

MESSAGE SYMBOLS
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
A 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
B 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 A
C C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
D D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
E E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
F F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
G G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
H H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
I I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
J J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
K K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
L L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
M M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
N N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
O O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
P P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
Q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
R R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
KEY SYMBOLS

S S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
T T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
U U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
V V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
W W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
X X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
Y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Z Z 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

Tasks
1. Encrypt the plaintext with different methods:
Substitution with Caesar Cipher using different keys
Substitution with Vigenère Cipher;
 "How to thank his father, so the child will thank you" the key word "son"
 "Five fingers on one hand and all the different" keyword "ruchenki"
 "The father - a mighty tree, a child - it leaves" key word "hierarchy"
 "While alive who knew his father was alive and his memory" key word "syllable"
 "Holiday dishes - the most exquisite dishes," keyword "feast"
 "well-fed do not understand the price of bread" the key word "hunger"
 "Money for people to make smart tool for fools - goal", keyword "gold"
 "Do not step over a dish of food", the keyword "value"
 "And the water - the food, if the soul is filed", keyword "tenge"
 "Daughter - a guest in the house", the key word "spouse"
2. Create the needed formulae in Excel to automated encoding and decoding the message

You might also like