Question: c language Transposition Cipher (loop) is a very simple transposition cipher encrypt can be described by the following rules: 1. If the length of S

c language

Transposition Cipher (loop) is a very simple transposition cipher encrypt can be described by the following rules:

1. If the length of S is 1 or 2, then encrypt(S) is S. 2.

2. For every 4 characters read in, switch the first two characters with the second two characters.

For example, encrypt("Ok") = "Ok" and encrypt("12345678") = "34127856".

Write a program to implement this cipher, given a text ?le input.txt. Start with the sample program found at page 437 (Program 7-8) as a basis for your program. In this program, lines 28 and 29 will be replaced by a call to encrypt declared below.

void encrypt( FILE* spInput, FILE* spOutput)

{

// you fill this out

}

Input Format

Lines 1... : The whole ?le (can be any number of lines) should be read in as a characters.

Sample Input (file Input.txt)

Test

Early

And often!

Output Format

Last Line: One integer: the total number of characters in the string

Lines 1next to last ling: The enciphered string

stTear

E

Aly ondenft!

21 Characters read

Output Explanation

Heres each character in the string as we are supposed to read it in, separated with . and so we can see the newlines, spaces and grouping of 4:

T.e.s.t .E.a.rl.y. .an.d. .of.t.e.n!.

The 1st four T.e.s.t. switch as s.t.T.e., the 2nd .E.a.r. switch as a.r. .E. this means a line return before E!

s.t.T.ea.r. .E .A.l.y. .o.n.de.n.f.t!

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!