0% found this document useful (0 votes)
4 views4 pages

CN Assignment

The document outlines an assignment for a Computer Networks course at Air University Islamabad, requiring students to develop an original encapsulation and decapsulation algorithm. Students must provide algorithm code, pseudocode, examples with screenshots, and a detailed description of their algorithm's functionality. An illustrative example is included, demonstrating a specific transformation method using ASCII values to encapsulate and decapsulate a string.

Uploaded by

mariamafzaal45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

CN Assignment

The document outlines an assignment for a Computer Networks course at Air University Islamabad, requiring students to develop an original encapsulation and decapsulation algorithm. Students must provide algorithm code, pseudocode, examples with screenshots, and a detailed description of their algorithm's functionality. An illustrative example is included, demonstrating a specific transformation method using ASCII values to encapsulate and decapsulate a string.

Uploaded by

mariamafzaal45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Air University Islamabad

Department of Software Engineering (CT)


Computer Networks
Assignment #1
Semester: Fall 2024 Max Marks:10
Date of Submission: October 15th, 2024 Class: BSCS 3rd

Instructor: Nasir Ayub


Instructions:
● Chatgpt is not allowed. Assignment will be canceled upon detection.

● Use this Template for submission including the Header.


Name: Mariam Afzaal Reg. No. 231139

Question No. 1

Develop an Original Encapsulation and Decapsulation Algorithm


You are required to create an original algorithm that performs encapsulation and decapsulation.
This can be implemented using any programming language of your choice (e.g., Python, C++,
Java). The algorithm should involve a unique way to transform data during encapsulation and to
reverse that transformation during decapsulation.
Deliverable Requirements:
1. Algorithm Code
Provide the full implementation of your encapsulation and decapsulation algorithm in a
programming language of your choice.
2. Pseudocode
Write a pseudocode that outlines the logical steps of your algorithm. This should be in a
simplified, language-neutral form that makes it easy to understand the overall flow.
3. Examples with Screenshots
Implement examples to demonstrate how your algorithm works, both in encapsulation and
decapsulation. Include screenshots of the code execution to illustrate these processes
clearly.
4. Description of Your Algorithm
Write a detailed description explaining how your encapsulation and decapsulation
algorithm works. Include important characteristics of the algorithm, such as how the
transformation occurs and the logic behind reversing the transformation.
Illustrative Example: Consider an encapsulation method based on name transformation. If
the name is "NASIR", an example of encapsulation could involve replacing each letter with
the next letter in the alphabet:

● N becomes O

● A becomes B

● S becomes T

● I becomes J

● R becomes S

Thus, "NASIR" is encapsulated as "OBTJS".


For decapsulation, you would reverse the transformation by converting each letter back to
the previous one in the alphabet, resulting in the original name, "NASIR".
Your Task:

● Design an original and creative transformation for the encapsulation and decapsulation
processes.

● Your approach does not need to be limited to alphabetical transformations—feel free to


explore numeric, symbolic, or even a mix of different methods.
PYTHON IMPLEMENTATION ALONG WITH THE OUTPUT:

Code:
def encapsulate(input_data):
encapsulated_message = ''.join([str(ord(character) + 3).zfill(3) for character in
input_data])
return encapsulated_message
def decapsulate(encapsulated_data):
split_chars = [encapsulated_data[i:i+3] for i in range(0, len(encapsulated_data), 3)]
decapsulated_message = ''.join([chr(int(chunk) - 3) for chunk in split_chars])
return decapsulated_message
initial_text = "AI2024"
encapsulated = encapsulate(initial_text)
decapsulated = decapsulate(encapsulated)
print(f"Initial Text: {initial_text}")
print(f"Encapsulated: {encapsulated}")
print(f"Decapsulated: {decapsulated}")

Description of the Algorithm:

Encapsulation Process:
It takes through the character present in the string which is being entered and it just counters the
input and increments the ASCII value of character by 3 and then returns the encrypted string.

A = ASCII value is 65 =Encapsulated: 068


I= ASCII value is 73= Encapsulated: 076
2 = ASCII value is 50 =Encapsulated: 053
0 = ASCII value is 48 = Encapsulated: 051
2 = ASCII value is 50 = Encapsulated: 053
4 = ASCII value is 52 =Encapsulated: 055
The encapsulated message becomes: "068076053051053055".

Decapsulation Process:

It takes through the encrypted string and then decrements the ASCII value of each character by 3
and then returns the decrypted string.

068 = Integer value is 68 = Original character: A


076 = Integer value is 76 = Original character: I
053 =Integer value is 53 =Original character: 2
051= Integer value is 51= Original character: 0
053 = Integer value is 53 = Original character: 2
055 = Integer value is 55 = Original character: 4
The decapsulated message is reconstructed as "AI2024".

Main Function:

Takes the string from the user and then prints the original one and then displays the encrypted one
and then displays the decrypted one and then the program exits.

You might also like