Creating a caesar cipher a character frequency generator


Assignment:

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.

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.

Solution Preview :

Prepared by a verified Expert
Computer Network Security: Creating a caesar cipher a character frequency generator
Reference No:- TGS01939270

Now Priced at $30 (50% Discount)

Recommended (98%)

Rated (4.3/5)