Purchase Solution

Caesar Cipher Programming

Not what you're looking for?

Ask Custom Question

See the attached file.
I am looking to get some help on an upcoming task that includes creating a Caesar cipher, a character frequency generator, and a combination of the two in order to use the frequency generator to decrypt a message using the highest frequency value as the key. The problem must be coded in c, c++, or python as I will be creating test harnesses/scripts within Linux.

Implement the Caesar cipher and develop tools that may be used to attack this cipher using a ciphertext only attack.

1) Cipher Implementation - caesarCipher

Implement an extended version of the Caesar cipher that uses the characters from ' ' (Space, ASCII 32) to '~' (tilde, ASCII 126). Any character (printable or not) that falls outside of the ASCII range of 32-126 should be left unchanged during both encryption and decryption (this will ensure that printable files will remain printable). Key values range from 0 to 94. Example with key=1:

Plaintext: Hello {~World~}!
Ciphertext: Ifmmp!| Xpsme ~"
Decrypted text: Hello {~World~}!

Command-line arguments should be used to indicate an input file (-i input_file), an output file (-o output_file), and an integer key value (-k key_value). An optional parameter (-d), when present, indicates that the input file is a ciphertext file that is to be decrypted.

Input files of up to 100 Kb in size should be accommodated.

2) Character Frequency Generator - charFreqGen

Design and implement a program that will take as input a text file and output a list of character frequency pairs, given the text within the file. The frequencies generated shall be case sensitive. This program may ignore all characters outside of the ASCII 32-126 range.

Command-line arguments should be used to indicate the file (-i input_file) from which the character frequencies are to be extracted as well as the output file (-o output_file) to which these frequencies are to be stored. The top character frequencies shall be displayed to the user in a sorted, two-column format. Characters shall be displayed in the first column, followed by their frequency in the second column. By default, the highest five character-frequency pairs shall be displayed, however this value may be overridden with a command-line parameter (-t top_count). Input file sizes of up to 100 Kb should be accommodated.

3) Ciphertext Attack Tool - caesarAttack

Design and implement a program that uses character frequency statistics generated by charFreqGen program to compute the correlation value, ø(i), for all possible key values. Once the ø(i) have been computed and sorted, decrypt the message using the key associated with the highest ø(i) value.

Note: If the a priori character frequencies are not representative of the plaintext message's character frequencies, the highest-ranked key may not decrypt the ciphertext. In order to allow for this, a command-line parameter may be used to select a lower-ranked key.

Command-line arguments should be used to indicate an input ciphertext file (-c ciphertext_file) and an input character frequency file (-f frequency_file). The top 5 ø(i) values should be displayed to the screen in sorted order, highest ø values first, with the key values listed in.

Attachments
Purchase this Solution

Solution Summary

Solution provides a C code, and does not do extensive error checking as it assumes fair input and fair code modification (for example, values of various macros). Code makes good use of C pre-processing features to make it quite generic and easy to experiment with. This solution also makes use of Makefile for easy compilation of code after code updates.

Solution Preview

Please extract the files from attached 558274.tgz using "tar zxvf 558274.tgz".

558274/
558274/caesarCipher.c
558274/charFreqGen.c
558274/common.c
558274/common.h
558274/Makefile
558274/caesarAttack.c

To compile the code, just type "make" at command line, when in directory 558274.

Solution ...

Purchase this Solution


Free BrainMass Quizzes
Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C++ Operators

This quiz tests a student's knowledge about C++ operators.