You are on page 1of 72

COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

LAB
WORKBOOK
20CS2222 COMPUTER NETWORKS & SECURITY

Team CNS
K L UNIVERSITY | COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

1
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

LAB WORKBOOK

STUDENT NAME

REG. NO

YEAR

SEMESTER

SECTION

FACULTY

2
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

CONTENTS

Organization of the STUDENT LAB WORKBOOK ........................................................... 5

FRAMING-Character Count #1 ............................................................................................ 9


Learning outcomes ................................................................................................................. 9
Pre- LAB Task: ...................................................................................................................... 9
In-LAB Task: ....................................................................................................................... 11
Post-LAB Task: .................................................................................................................... 13
FRAMING-Bit Stufffing #2 .................................................................................................. 14
Learning outcomes ............................................................................................................... 14
Pre- LAB Task: .................................................................................................................... 14
In- LAB Task: ...................................................................................................................... 16
Post-LAB Task: .................................................................................................................... 19
ERROR DETECTION - CRC #3 ......................................................................................... 21
Learning out comes .............................................................................................................. 21
Pre-LAB Task: ..................................................................................................................... 21
In-LAB Task: ....................................................................................................................... 23
Post-LAB Task: .................................................................................................................... 26
ERROR CORRECTION - Hamming Code #4 ................................................................... 28
Learning out comes .............................................................................................................. 28
Pre-LAB Task: ..................................................................................................................... 28
In-LAB Task: ....................................................................................................................... 31
Post-LAB Task: .................................................................................................................... 33
ERROR DETECTION - LRC #5 ......................................................................................... 34
Learning out comes .............................................................................................................. 34
Pre-LAB Task: ..................................................................................................................... 34
In-LAB Task: ....................................................................................................................... 36
Post-LAB Task: .................................................................................................................... 38
ROUTING ALGORITHM - SPA#6..................................................................................... 39
Learning out comes .............................................................................................................. 39
Pre-LAB Task: ..................................................................................................................... 39
In-LAB Task: ....................................................................................................................... 41
Post-LAB Task: .................................................................................................................... 43
ROUTING ALGORITHM - DVR #7 ................................................................................. 44
Learning out comes .............................................................................................................. 44
3
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Pre-LAB Task: ..................................................................................................................... 44


In-LAB Task: ....................................................................................................................... 46
Post-LAB Task: .................................................................. ………………………………..48
CLASSIC ENCRYPTION TECHNIQUES #8 ................................................................... 49
PART-A - Caeser Cipher Technique ................................................................................... 49
Learning outcomes ............................................................... …………………………… 49
Pre-LAB Task: ..................................................................................................................... 49
In-LAB Task: ....................................................................................................................... 51
Post-LAB Task: .................................................................................................................... 53
PART-B - Playfair cipher Technique................................................................................... 55
Learning outcomes ............................................................................................................... 55
Pre-LAB Task: ..................................................................................................................... 55
In-LAB Task: ....................................................................................................................... 57
Post-LAB Task: .................................................................................................................... 59
Rail Fence Technique #9 ...................................................................................................... 61
Learning outcomes ............................................................................................................... 61
Pre-LAB Task: ..................................................................................................................... 61
In-LAB Task: ....................................................................................................................... 63
Post-LAB Task: .................................................................................................................... 65
RSA#10.................................................................................................................................... 68
Learning outcomes ............................................................................................................... 68
Pre-LAB Task: ..................................................................................................................... 68
In-LAB Task: ....................................................................................................................... 70
Post-LAB Task: .................................................................................................................... 72

4
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

5
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Organization of the STUDENT LAB WORKBOOK:


The laboratory framework includes a creative element but shifts the time-
intensive aspects outside of the Two-Hour closed laboratory period. Within this
structure, each laboratory includes three parts: Prelab, In-lab, and Post-lab.

a. Pre-Lab
The Prelab exercise is a homework assignment that links the lecture with the
laboratory period - typically takes 2 hours to complete. The goal is to
synthesize the information they learn in lecture with material from their
textbook to produce a working piece of software. Prelab Students attending a
two-hour closed laboratory are expected to make a good-faith effort to
complete the Prelab exercise before coming to the lab. Their work need not
be perfect, but their effort must be real (roughly 80 percent correct).

b. In-Lab
The In-lab section takes place during the actual laboratory period. The First hour
of the laboratory period can be used to resolve any problems the students might
have experienced in completing the Prelab exercises. The intent is to give
constructive feedback so that students leave the lab with working Prelab software
- a significant accomplishment on their part. During the second hour, students
complete the In-lab exercise to reinforce the concepts learned in the Prelab.
Students leave the lab having received feedback on their Prelab and In-lab work.
c. Post-Lab
The last phase of each laboratory is a homework assignment that is done
following thelaboratory period. In the Post-lab, students analyze the efficiency or
utility of a given system call. Each Post-lab exercise should take roughly 120
minutes to complete.

6
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

2021-22 EVEN SEMESTER LAB CONTINUOUS EVALUATION

In-Lab
Pre Post Viva Total
Experiment Faculty
Sno Date Lab Lab Voce (50M)
Name Signature
(5M) LOGIC EXECUTION RESULT ANALYSIS (5M) (5 M)
(10M) (10M) (10M) (5M)

1.

2.

3.

4.

5.

6.

7
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

7.

8 (a).

8(b).

9.

10.

Total

8
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 1: Write a python program to implement the character count and stuffing character
using framing method.
Date of the Session: / / Session Time: to

Learning outcome:
• Understanding of framing concept
• Understanding of character count and stuffing character

Pre-Lab Task:

(i) Give details about framing?

(ii) Define character stuffing?

(iii) Explain about different types framing methods?

9
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

10
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Rex is a developer in foster technology has just started learning about various framing concepts
and interested in learning character count and character stuffing. Rex a newbie
In this area, you are requested by Rex to help him to implement the character count and character
stuffing.
Writing space for the Problem: (For Student’s use only)

11
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

12
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task


1. The following character encoding is used in a data link protocol:
A: 01000111; B: 11100011; FLAG: 01111110; ESC: 11100000
Show the bit sequence transmitted (in binary) for the four-character frame:
A B ESC FLAG
Apply Character count on the transmitted data.

2. What are the advantages and disadvantages of character count and Stuffing
character?

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

13
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 2: Write a python program to implement the bit stuffing concept using framing
methods.
Date of the Session: / / Session Time: to

Learning outcome:
• Understanding of Bit Stuffing concept
• Understanding of Byte stuffing concept

Pre-Lab Task:

(i) List the different types of stuffing?

(ii) What is Bit Stuffing and byte stuffing?

(iii) Distinguish bit and byte stuffing in framing?

14
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

15
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Rex has understood the character count and character stuffing concepts in Framing methods. At
present Rex is interested to implement bit stuffing concept. Now help Rex to implement Bit
stuffing concept using python Language.
Writing space for the Problem: (For Student’s use only)

16
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

17
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

18
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task


The following character encoding is used in a data link protocol: A: 01000111; B: 11100011;
FLAG: 01111110; ESC: 11100000 Show the bit sequence transmitted (in binary) for the four-
character frame: A B ESC FLAG when each of the following framing methods are used:
(a) Flag bytes with byte stuffing.

(b) Starting and ending flag bytes, with bit stuffing.

Writing space for the Problem: (For Student’s use only)

19
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

20
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 3: Write a python program to implement the Cyclic Redundancy Check (CRC) Method.
Date of the Session: / / Session Time: to

Learning outcome:
• Understanding the Concept of Error Detection Code.
• Understanding the Concept of CRC.

Pre-Lab Task:
(i) What do you mean by redundancy?

(ii) Define cyclic redundancy check (CRC).

(iii) List the types of Error Detection Codes.

21
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

22
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Rex is so confused with the framing concepts, he is not understanding how to implement CRC, he
was puzzled with the Error Detection Code, now assist Rex to understand how to implement the
CRC Technique in Error Detection Code.
Writing space for the Problem:(For Student’s use only)
Sender Side

23
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

24
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

25
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:


A bit stream 1101011011 is transmitted using the standard CRC method. The generator
polynomial is x4+x+1. What is the actual bit string transmitted?
Writing space for the Problem:(For Student’s use only)

26
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

27
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 4: Write a python program to implement the Hamming Code.


Date of the Session: / / Session Time: to

Learning outcome:

• Understanding the Concept of Error Correction Code.


• Understanding the Concept of Hamming Code.

Pre-Lab Task:
(i) What is Hamming Code?

(ii) List the Error Correction Codes.

(iii) Define Parity bit and Redundancy bit?

28
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

29
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

30
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Rex is so confused with the framing concepts, he is not understanding how to implement Hamming
Code, he was puzzled with the Error Correction Code, now assist Rex to understand how to
implement the Hamming Code in Error Correction Code.
Writing space for the Problem: (For Student’s use only)

31
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

32
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:


1. Encode the data 1101 in even parity, by using Hamming code.

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

33
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 5: Write a python program to implement the 2-D Parity check.

Date of the Session: / / Session Time: to

Learning Outcome:
• Understanding the Longitudinal Redundancy Check (LRC)
• Understanding the Error Detection Code

Pre-Lab Task:
(i) What is meant 2-D Parity Check?

(ii) List the different types of Error Detection Techniques?

(iii) Differentiate simple parity check and 2-D parity Check?

34
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

35
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Rex didn’t understand the Error Detection Codes particularly in LRC Technique. He wants to Gain
Knowledge on different error detection codes, so help Rex to implement 2-D Parity Check.
Writing space for the Problem: (For Student’s use only)

36
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

37
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:


(i) Mention the Draw backs of Single Parity check and 2-D Parity check?

(ii) Suppose that a packet’s payload consists of 10 eight-bit values (e.g.,


representing ten ASCII-encoded characters) shown below. (Here, we have
arranged the ten eight-bit values as five sixteen-bit values):
10101111 10010110
00010010 10001100
10100001 10001110
10111100 01101100
01011011 10100010
Compute the two-dimensional parity bits for the 16 columns. Combine the
bits into one string

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

38
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 6: Write a python Program to implement shortest path routing


Date of the Session: / / Session Time: to

Learning outcome:
• Understanding the shortest path Algorithm concepts
• Understanding the Packet Routing concept

Pre-Lab Task:
(i) Define routing?

(ii) What is meant by Dijkstra's shortest path algorithm?

(iii) List the various types of shortest path algorithms?

39
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

40
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Rex perplexed with different types of routing Algorithms in network. He wants to understand
shortest path algorithm in routing algorithms, so assist Rex to implement shortest path Algorithm.
Writing space for the Problem:(For Student’s use only)

41
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

42
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:

(i) List out the Advantages of Shortest path Algorithms (SPA)?

(ii) Find the shortest distance from A to H on the network below.

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

43
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 7: Write a python Program to implement Distance Vector Routing (DVR)


Date of the Session: / / Session Time: to

Learning outcome:
• Remembering the different types Routing
• Understanding the Distance Vector Routing

Pre-Lab Task:
(i) What is Distance Vector Routing?

(ii) Why Routing is important in Computer Networks?

(iii) List the classification of Routing algorithm?

44
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

45
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Rex puzzled with different types of routing Algorithms in network. He wants to understand
Distance Vector Routing algorithm in routing algorithms, so assist Rex to implement DVR.
Writing space for the Problem:(For Student’s use only)

46
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

47
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:


1. Rajesh implements the distance-vector protocol on the network shown below. Each node
has its own local clock, which may not be synchronized with any other node's clock. Each
node sends its distance-vector advertisement every 100 seconds. When a node receives an
advertisement, it immediately integrates it. The time to send a message on a link and to
integrate advertisements is negligible. No advertisements are lost. There is no HELLO
protocol in this network.

1. At time 0, all the nodes except D are up and running. At


time 10 seconds, node D turns on and immediately sends a
route advertisement for itself to all its neighbors. What is the
minimum time at which each of the other nodes is guaranteed
to have a correct routing table entry corresponding to a
minimum-cost path to reach D? Justify your answers.

2. If every node sends packets to destination D, and to no other destination, which


link would carry the most traffic?

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

48
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 8 (a): Write a Python Program to implement the Caesar cipher technique
Date of the Session: / / Session Time: to

Learning outcome:
• To understand Symmetric Crypto System.
• To understand the concept of Encryption and Decryption.
• To implement the concept of Onetime pad.

Pre-Lab Task:
(i) What is the need for encryption?

(ii) What is meant by symmetric cryptosystems? Explain its applications.

(iii) Describe one time pad.

49
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

50
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Rex sent a message “hey” to Kevin through an insecure channel (it could be a wireless channel or
internet or courier or any channel that we cannot trust). Here, Robert is an eavesdropper. He always
tries to corrupt the message sent by Rex. To avoid this let’s encrypt the message sent by Rex using
a key ‘K’ which can be shared with the receiver, so that Robert cannot access the actual message.
He can only access the cipher text (encrypted message). Once the message is received by Kevin, he
must perform a decryption process using shared key to read the actual message sent by Rex.
Sample input :
Enter the msg: Sampleinput enter key :764

Sample output :
The encrypted msg is zgqwripttbz
The decrypted msg is : sampleinput
Writing space for the Problem:(For Student’s use only)

51
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

52
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:


(i) Julius Caesar and Cleopatra often exchanged letters in an encrypted form using the Caesar
cipher. Write the code for encryption and decryption of the message.
Sample Input: Original Message – MISSING
Shift Value – 3 Sample Output:
Encrypted Message- plvvlq

53
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

54
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 8 (b): Write a Python Program to implement the Playfair cipher technique
Date of the Session: / / Session Time: to

Learning outcome:
• To understand how to construct a 5*5 matrix using the key in Playfair cipher.
• To understand how to construct a digraph in Playfair cipher.
• To learn how to encrypt and decrypt a message using a key in Playfair cipher.

Pre-Lab Task:
(i) What is Playfair cipher?

(ii) How do we construct a matrix in Playfair cipher?

(iii) What to do if letters in plain text reoccur?

55
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

(iv) What are the advantages of Playfair cipher?

(v) Trace what will the encrypted message be using Playfair cipher if the message is
‘balloon’ and the key is ‘monarchy’.
Step1

56
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Bryce Walker saves the tapes and polaroids of Hannah Baker and Jessica Davis in a box. He
locked the box by encrypting the plain text “thirteenreaonswhy” using the key “tapes”. The
encryption technique used by him is Playfair cipher. To identify the cipher write a program.

Sample Input:- Tapes “THIRTEENREASONSWHY”

Sample Output:- “BNLOASTRFPTQOAZIV”


Writing space for the Problem:(For Student’s use only)

57
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

58
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:


(i) Clay Jensen, who wants to get justice for Hannah and Jessica, finds out about Bryce’s
box. He wants to get the polaroid’s and the tapes from it. After his enormous efforts,
he finds out from Justin Foley the key used by Bryce was ‘tapes’, the encrypted text
was like ‘BNLOASTRFPTQOAZIV’ and the technique used by him was Playfair.
Help Clay to decrypt the lock.
Sample Input:- BNLOASTRFPTQOAZIV
Sample Output:- THIRTEENREASONSWHY

59
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

(ii) What are the limitations of Playfair cipher?

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

60
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 9: Write a Python Program to implement the rail fence technique


Date of the Session: / / Session Time: to

Learning outcome:
• To understand the concept of transposition ciphers
• To understand and implement the rail fence cipher.

Pre-Lab Task:
(i) What is transposition cipher?

(ii) Difference between transposition cipher and substitution cipher.

(iii) What are the applications of rail-fence cipher?

(iv) How to break a rail-fence cipher?

61
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

62
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
The major of Indian army wants to store data about Naval submarine, S21in an encrypted manner
to safeguard it from the Pakistan army. He stores the data in various locations in the form of small
chunks.The Major used railfence cipher with three rails to encrypt the data.Pakistan army may find
about the data and may try to decrypt it. Help Indian army to encrypt the data and find how might
have the pakistan army decrypted it.
Input:- S21atlocation56
Output: Stan2alcto51oi6
Writing space for the Problem:(For Student’s use only)

63
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

64
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:


(i) The major of Indian Army wants to increase the complexity of the encryption,
so instead of using three rails he wants to use ‘n’ rails to encrypt the data
.Write a Python code to help major to encrypt the data with n rails.
Sample input:- N=6 Message=S21location56
Sample output:- Si2to1anac5to6l

65
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

66
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

67
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


SUBJECT CODE: 20CS2222AA/20CS2222PA
COMPUTER NETWORKS AND SECURITY LAB WORKBOOK

Lab 10 : Write a Python Program to implement the RSA


Date of the Session: / / Session Time: to

Learning outcome:
• To understand the concept of Asymmetric encryption.
• To understand and implement the concept of RSA Algorithm.

Pre-Lab Task:

(i) What is asymmetric key encryption?

(ii) Explain the steps of RSA Algorithm using an example.

68
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

69
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

In Lab Task:
Crypto Bank has exciting offers for new customers at their bank with state-of-the-art security
features such as RSA algorithm encryption. Dave wants to deposit his bitcoin savings into
their bank and avail the offers. He contacts the bank and gets their Public Key. He then
proceeds to encrypt the currency data using the bank’s public key and sends the encrypted
data to the bank representatives. The bank acknowledges the receipt of delivery and proceeds
to decrypt the data using their Private key. The bank thus safely acquires the Bitcoin currency
and stores it in their vault. Implement this scenario.
Sample Input:
3 //value of p
7 //value of q
5 //value of e
2 //value of k
20 //value of msg
Sample Output:
Message data = 20.000000
Encrypted data = 20.000000
Original Message sent = 20.000000
Writing space for the Problem:(For Student’s use only)

70
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

71
COMPUTER NETWORKS AND SECURITY – 20CS2222AA/20CS2222PA

Post Lab Task:


(i) List the possible attacks on the RSA Algorithm and explain at least 3.

(For Evaluator’s use only)

Comment of the Evaluator (if Any) Evaluator’s Observation


Marks Secured: out of

Full Name of the Evaluator:

Signature of the Evaluator


Date of Evaluation:

72

You might also like