Sunteți pe pagina 1din 8

Basic Cryptography

Practical Exercise
Classical to Modern Cryptography mode of exercises

Classical Cryptography
Shift Cipher
The Shift (or Caesar) Cipher is another monoalphabetic substitution cipher. Although more secure than
the Atbash Cipher, it is still an easy cipher to break, especially by today's standards. Originally, it was
used by Julius Caesar for sending encrypted messages to his troops, as recorded by Suetonius:
If he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters
of the alphabet that not a word could be made out. If anyone wishes to decipher these, and get at their
meaning, he must substitute the fourth letter of the alphabet, namely D, for A, and so with the others.
(Suetonius, the Twelve Caesars)
-

Exercise 1

Use the Shift Cipher to encrypt the following message


Plaintext:

Beware the Ides of March.

Key:

Exercise 2

Use the Shift Cipher to decrypt the following message


Ciphertext:

RFC AYCQYP QFGDR

Key:

-2

Affine Cipher
The Affine Cipher is another example of a Monoalphabetic Substituiton cipher. It is slightly different to
the other examples encountered here, since the encryption process is substantially mathematical. The
whole process relies on working modulo m (the length of the alphabet used). By performing a calculation
on the plaintext letters, we encipher the plaintext.
-

Exercise 3

Use the Affine Cipher to encrypt the following message


Plaintext:

A simple message

Key:

a = 7, b = 13

Page 1 of 7

Exercise 4

Use the Affine Cipher to decrypt the following message


Ciphertext:

NCDQWTQP FQ CEL NEFRMWLYN FA PTDQCN

Key:

a = 15, b = 3

Vigenre Cipher
Vigenre Cipher was actually first described by Giovan Battista Bellaso in his 1553 book La cifra del.
Sig. Giovan Battista Bellaso. However, in the 19th Century, it was misattributed to Blaise de Vigenre,
who had presented a similar cipher (the Autokey Cipher) in 1586.
At the time, and for many centuries since its invention, the Vigenre Cipher was renowned for being a
very secure cipher, and for a very long time it was believed to be unbreakable. It was this thought that
earned it the nickname "le chiffre indchiffrable" (French for "the unbreakable cipher"). Although this is
not true (it was fully broken by Friedrich Kasiski in 1863), it is still a very secure cipher in terms of paper
and pen methods, and is usable as a field cipher.
-

Exercise 5

Use Vigenere Cipher to encrypt the following message


Plaintext:

The Alberti Cipher was a revelation.

Key:

vigenere

Exercise 6

Use the Vigenere Cipher to decrypt the following message


Ciphertext:

KLTMJDQSXFXYHLWLTMEZMNTPYJ

Key:

alberti

Page 2 of 7

Enigma
-

Exercise 7

Use the Enigma Cipher to encrypt the following message


Plaintext:

Beware the Ides of March.

Key:

[Develop and state your own key]

Enigma Cipher
The Enigma cipher was a field cipher used by the Germans during World War II. The Enigma is one of
the better known historical encryption machines, and it actually refers to a range of similar cipher
machines. The first Enigma machine was invented by a German engineer named Arthur Scherbius at the
end of the first world war. It was used commercially from the early 1920s on, and was also adopted by the
military and governmental services of a number of nations most famously by Nazi Germany before
and during World War II. A variety of different models of Enigma were produced, but the German
military model, the Wehrmacht Enigma.

The Algorithm
This section will talk about the Enigma I aka Wehrmacht Enigma, other variants are similar in operation.
The 'key' for the enigma consists of several elements:
1. The rotors and their order
2. The rotor start positions
3. The ringstellung, or ring settings
4. Steckerverbindungen, or plug board settings

Page 3 of 7

Modern Cryptography
1) Stream Cipher One-time pad encoder/decoder and key generator
The one-time pad (OTP) encryption technique is the only proven unbreakable encryption system.
Even infinite computational power and time cannot break this system.
Implementation of the one-time pad system
This tool allows you to enter a message in any language, e.g.: English, Chinese, Russian etc.
All texts are considered UTF-8 encoded.
UTF-8 is a multibyte encoding that can represent any Unicode character in 1 to 4 bytes.

ASCII characters (U+0000 to U+007F) take 1 byte


Code points U+0080 to U+07FF take 2 bytes
Code points U+0800 to U+FFFF take 3 bytes
Code points U+10000 to U+10FFFF take 4 bytes

The message Operation start at 10:00 consists of 24 ASCII characters, thus total 24 bytes.
Each character in the message will be converted into a hexadecimal value, for example:
4f7065726174696f6e2073746172742061742031303a3030
To encrypt the message you need a randomly generated number called a one-time pad, for
example:
a33a986b3f8b111dfbfb1d2e6f0934748fba6efc07a9fab9
XOR the message and one-time pad to create the cipher :
message:
4f7065726174696f6e2073746172742061742031303a3030
one-time pad: a33a986b3f8b111dfbfb1d2e6f0934748fba6efc07a9fab9
------------------------------------------------ xor
cipher:
ec4afd195eff787295db6e5a0e7b4054eece4ecd3793ca89
To decrypt the cipher, XOR the cipher and the same one-time pad:
cipher:
ec4afd195eff787295db6e5a0e7b4054eece4ecd3793ca89
one-time pad: a33a986b3f8b111dfbfb1d2e6f0934748fba6efc07a9fab9
------------------------------------------------ xor
message:
4f7065726174696f6e2073746172742061742031303a3030
Convert the message hexadecimal value to UTF-8 and you get:
Operation start at 10:00
How to use the one-time pad system
1. Bob and Alice wants to exchange multiple messages secretly using the one-time pad
system.
2. Bob generates a list of one-time pads, each one-time pad contains a prefix reference
number.
3. Bob stores the list on two USB flash drives.
Page 4 of 7

4. Bob and Alice meet each other in a restaurant and Bob hand over one of the USB flash
drives.
5. At home Bob creates a message and encrypts it with a one-time pad from the list.
The encrypted message (cipher), also contains a prefix referring to the one-time pad used.
6. After encryption Bob deletes the used one-time pad from his list.
7. Bob sends the cipher to Alice using his email.
8. Alice receives the cipher. She looks at the cipher prefixed number and knows which onetime pad she must use to decrypt the cipher.
9. Alice decrypts the cipher using the one-time pad from her list.
10. After Alice has decrypted the message, she deletes the used one-time pad from her list.
The one-time pad system cannot be cracked if the following rules are applied correctly:

The one-time pad should be a randomly generated key.


The one-time pad should only be used once.
Only the sender and receiver should have copies of the on-time pad. If more parties have a
copy, the chance will increase an attacker get hold of a copy.
The one-time pads must be exchanged via a secure channel, preferably meeting face to
face and the data stored on a USB flash drive.
The one-time pad is at least as long as the message that must be encrypted.

Exercise 8

Use One-time Pad to encrypt the following message


Plaintext:
Key / One-time Pad:

Beware the Ides of March.


[Develop and state your own key]

Exercise 9

Use One-time Pad to encrypt the following message

Plaintext:

A simple message

Key / One-time Pad:

[Develop and state your own key]

http://www.mobilefish.com/services/one_time_pad/one_time_pad.php#one_time_pad_output

Page 5 of 7

2) Symmetric Block Cipher Algorithms


There are a number of symmetric block cipher algorithms. We will examine the most widely used and
those with the most influence on the field of cryptography.
1. DES
2. 3DES
3. AES
4. Blowfish
5. Blowfish-compat
6. Rijndael 128
7. Rijndael 192
8. Rijndael 256
9. Twofish
10. Serpent
11. RC2
12. GOST
-

Exercise 10

Use the Symmetric Block Cipher Algorithms above to encrypt the following messages
1. Plaintext:

Beware the Ides of March.

Key:
Mode:
Input:

[Develop and state your own key]


[Select and state your mode]
[State whether you use hexa or base64]

2. Plaintext:

A simple message

Key:
Mode:
Input:

[Develop and state your own key]


[Select and state your mode]
[State whether you use hexa or base64]

Encryption tools: https://www.tools4noobs.com/online_tools/encrypt/


Decryption tools: https://www.tools4noobs.com/online_tools/decrypt/

Page 6 of 7

File checksum calculator


This service allows you to verify the integrity of downloaded files by calculating its checksum. A
checksum is a way to ensure that a file has not been altered in any way from the original version. Many
websites provide checksums along with their setup files so that you can be sure of the integrity of the file.
This tool only works on the recent version of Firefox , Chrome and Opera and calculates the most
commonly used file checksum algorithms:
1. MD5

The MD5 (Message Digest) algorithm produces a 128-bit (16-byte) hash value, typically
expressed in text format as a 32 digit hexadecimal number.

2. SHA1
SHA1 (Secure Hash Algorithm) algorithm produces a 160-bit (20-byte) hash value,
typically expressed in text format as a 40 digit hexadecimal number.
3. SHA224
SHA224 (Secure Hash Algorithm) algorithm produces a 224-bit (28-byte) hash value,
typically expressed in text format as a 56 digit hexadecimal number.
4. SHA256
SHA256 (Secure Hash Algorithm) algorithm produces a 256-bit (32-byte) hash value,
typically expressed in text format as a 64 digit hexadecimal number.
5. SHA384
SHA384 (Secure Hash Algorithm) algorithm produces a 384-bit (48-byte) hash value,
typically expressed in text format as a 96 digit hexadecimal number.
6. SHA512
SHA512 (Secure Hash Algorithm) algorithm produces a 512-bit (64-byte) hash value,
typically expressed in text format as a 128 digit hexadecimal number.
7. RIPEMD160
RIPEMD160 (RACE Integrity Primitives Evaluation Message Digest) algorithm
produces a 160-bit (20-byte) hash value, typically expressed in text format as a 40 digit
hexadecimal number.
The file you upload and the calculated hash will never be sent to the server. All calculations are
performed directly in the browser using Javascript.
http://www.mobilefish.com/services/file_checksum_calculator/file_checksum_calculator.php

Page 7 of 7

S-ar putea să vă placă și