Question: CS 1410 XOR Permutation Cipher Instructions : Write a C++ program that will: 1. Input a 7 bit key from a file. This file must

CS 1410

XOR Permutation Cipher

Instructions: Write a C++ program that will:

1. Input a 7 bit key from a file. This file must be entitled exactly "key.txt".

2. Input a plaintext message of any size from a file entitled "plaintext.txt".

3. For every character in the plaintext message, perform the following tasks to encrypt it: a. Compute its base 10 ASCII value

b. Convert the base 10 number into an equivalent 7 bit unsigned binary number

c. Permute the bits of the 7 bit binary number according to the following permutation:

?

permuated_bits[0] = original_bits[2]

permuated_bits[1] = original_bits[5]

permuated_bits[2] = original_bits[6]

permuated_bits[3] = original_bits[4]

permuated_bits[4] = original_bits[1]

permuated_bits[5] = original_bits[3]

permuated_bits[6] = original_bits[0]

d. XOR the permuted_bits with the key to compute the ciphertext bits.

e. Output to the console screen the 7 ciphertext bits for that plaintext character.

4. Output a Carriage Return (endl) so that there are only 7 ciphertext bits per line.

Note: To conserve memory and to partially simulate how this would be implemented at the machine level, you must use the C++ bitset in order to store the following:

1. Plaintext bits

2. Key bits

3. Cipertext bits

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!