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

FOCP-Assignment 2

focp

Uploaded by

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

FOCP-Assignment 2

focp

Uploaded by

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

FOCP-Assignment 2

National University of Sciences & Technology (NUST)


School of Electrical Engineering and Computer Science (SEECS)
Faculty of Computing

CS 110: Fundamentals of Computer Programming


Assignment # 2
Assignment Date: 10/11/2024 Due Date: Friday, 22/11/2023, Marks: 20
(23:59)
CLO Attainment: [CLO-2] Solve given real-world problem by applying appropriate
programming concepts and techniques

Assignment Title: Deciphering Encrypted Code Using Frequency Analysis Algorithm


Overview:
In this assignment, students will design a C++ program to encrypt text using a simple substitution-
based cipher (such as Caesar, Atbash, Substitution, Affine) and then attempt to break it using
frequency analysis. The assignment allows students to explore both encryption and cryptanalysis
techniques, focusing on substitution ciphers that can be decrypted with frequency analysis.
Learning Objectives:

• Apply encryption and decryption techniques to understand data security principles.


• Use frequency analysis to decrypt text encrypted with substitution ciphers.
• Implement modular programming with clear function boundaries for encryption and
decryption.
• Strengthen coding practices through problem-solving in cryptography.
Design Requirements:

• High-Level Design:
o Identify the primary modules (e.g., text input, encryption, frequency analysis,
decryption).
o List programming constructs like loops, arrays, conditionals, functions, and basic
file I/O if applicable.
o Create flowcharts to represent the encryption and decryption processes, from
input to frequency analysis and decryption output.
o Define main functions and their roles: encryptText(), frequencyAnalysis(),
decryptText(), and compareResults().
• Data Design: Choose appropriate data types to store your data.
• Algorithm Design:
o Implement a Frequency Analysis Algorithm to count occurrences of each letter in
the cipher text.

1|Page
FOCP-Assignment 2

o Build a substitution key based on frequency data and common English letter
distributions to decrypt the cipher text.
Implementation Requirements:

• Input:
o Prompt the user to enter a plain text message for encryption.
o Allow the user to choose an encryption method from any two (if two group
members)/three (if three group members) options, such as Caesar Cipher, Atbash
Cipher, or Monoalphabetic Substitution Cipher.
o Ensure input validation for alphabetic text only (no numbers or symbols).
• Encryption:
o Encrypt the text using the chosen cipher. Output the encrypted message to show the
result.
• Frequency Analysis Alf=gorht:
o Perform frequency analysis on the encrypted message to calculate the most common
letters.
o Using frequency data, generate a probable substitution key and attempt to decrypt
the text.
o Output the decrypted message and compare it to the original input to assess accuracy.
• Error Handling: Include error handling for invalid input and cases where decryption may not
fully match the original text.
• Modularity: Design the program with modularity in mind. Break down the code into functions
to promote reusability and maintainability. Organize the code with modular functions like
encryptText(), frequencyAnalysis(), decryptText(), and outputResults().
• Code Style and Best Practices: Follow C++ coding standards with meaningful variable names,
indentation, and comments.
• Testing and Validation: Develop a testing plan to validate encryption and decryption results,
including a variety of inputs and ciphers.
Document Requirements:
Write a brief report explaining the encryption and decryption processes, frequency analysis, and
testing results.
Include code snippets, screenshots of encryption and decryption output, and documentation for
each function. Demo and viva will be conducted in the lab.
Submission Criteria:

• This is a group assignment.


• Submit the assignment in the form of a .zip folder using the nomenclature
FirstMemberName-SecondMemberName-ThirdMemberName-Class-Section.zip on the
LMS.

2|Page
FOCP-Assignment 2

• Inside the .zip folder, include the following:


o A design report in the .pdf document format using the nomenclature
FirstMemberName-SecondMemberName-ThirdMemberName-Class-
Section.pdf. Clearly mention the names of each group member on the title page.
o A well-commented C++ code saved as FirstMemberName-
SecondMemberName-ThirdMemberName-Class-Section.cpp file.
Only group leader (name should be highlighted) should submit the .zip folder in LMS to allow
marking. The names and task division of each group member should be clearly mentioned in the
report. Late submissions are accepted with penalty. Plagiarism will be marked zero.
Grading Rubric

Component Criteria Excellent Needs Improvement Inadequate


(2) (1) (0)
Input validation Missing or
Input Handling Accurate validation of exists but allows inadequate
alphabetic input only. minor errors. input validation.

Encryption Correct application of Encryption is Incorrect


Implementation chosen encryption partially correct or encryption
method. inconsistent. implementation.
Frequency
Correctly implemented analysis is
Frequency Analysis
and accurate frequency Frequency analysis is missing or
counts for decryption. partially correct. incorrect.
Implementation
Effective decryption No decryption
Decryption Attempt using frequency-based Partial decryption or entirely
key. with some errors. incorrect.

Code Style and Best Well-commented, Some comments or Poor or no


Practices follows coding minor standard comments, lack
standards. issues. of standards.
Lack of
Partial modularity modularity,
Modularity
Code is well-structured with some redundant or
into functions. redundant code. unclear code.
No clear
flowchart or
High-Level Design Clear flowchart and Partial design with main
explanation of main some flowchart component
Design components. elements missing. outline.
Clear algorithm for Basic algorithm with Algorithms are
Algorithmic Design encryption and some gaps or missing or
decryption. unclear steps. inaccurate.
Comprehensive test No test cases or
Documentation Thorough Testing Plan cases for encryption Limited test cases insufficient
and decryption. with minor gaps. validation.

3|Page
FOCP-Assignment 2

Clear report with Missing or


Documentation explanations and Report is incomplete inadequate
screenshots. or lacks clarity. documentation.

4|Page

You might also like