Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Must be in c code please Goal of this assignment: To be able to 1) work with str

ID: 3815306 • Letter: M

Question


Must be in c code please Goal of this assignment: To be able to 1) work with strings, 2) work with functions, 3) write pseudocode 5 translate pseudocode to C program, and 6) test programs thoroughly. Introduction: Cryptography is the science of making messages secure, of transforming readable messages into unreadable messages and back again. Messages that are unreadable are called ciphertext. The process of turning plaintext into ciphertext is called encryption. The reverse process of turning ciphertext into plaintext is called decryption. One of the easiest ways to encrypt a message is to scramble the letters. For example the word "apple" could be randomly transformed to "lapep." In fact there are 120 different possible arrangements of the word "apple." However, if the encryption algorithm randomly scrambles the letters, the task of the decryption algorithm is pretty hard. Encryption and decryption algorithms must work together in some agreed upon way, with the encryption algorithm scrambling letters and the decryption algorithm unscrambling them. A transposition cipher is one way to scramble the letters of a message. The cipher separates the message into two groups of characters: the first group composed of the even-numbered characters and the second group composed of the odd-numbered characters. To produce the ciphertext, the cipher puts together both groups; placing the group of the even-numbered characters first, followed by the group of odd-numbered characters. This encryption results in a string with the characters shuffled to new positions. Project: Ask user to enter a string, write a function that takes the string as a parameter, encrypt the message as described above and returns the ciphertext. Then ask user again if she/he wants to continue or not. Finally print all the original messages in alphabetically ascending order. Example: Please enter a message Fight, Matadors, for Tech! The encrypted message is Do you want to continue (Y/N)? Y Please enter a message: Bear our banners far and wide. The encrypted message is: i.e., The original messages in alphabetical order are: Bear our banners far and wide Fight Matadors for Tech! String functions: Design your solution to use the string library functions. You must be able to incorporate the use of strien() (to check length of the message string), strcat() (to concatenate the even and odd characters string) and strcmp() (for final alphabetical order) into the solution.

Explanation / Answer

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
  
char org[30];
char se[30];
char so[30];
char ch;
char st[100];
char temp;
int l,i,a,b,j;
a=0;
b=0;
do
{
printf("Please enter a message : ");
scanf("%s",&org);
//l=strlen(org);
for(i=0;i<30;i++)
{
if(i%2==0)
se[a++]=org[i];
else
  
so[b++]=org[i];
}
//printf("%s",org);
printf("The encrypted message is ");
printf("%s",se);
printf("%s",so);
printf(" ");
printf("Do you want to continue (Y/N) ");
scanf("%s",&ch);
memset(se ,0, sizeof(se));
memset(so ,0, sizeof(so));
memset(org ,0, sizeof(org));
a=0;
b=0;
strcpy(org,st);
}while(ch!='N');
for(i=1;i<l;i++)
for(j=0;j<l-i;j++)
if(st[j]>st[j+1])
{
temp=st[j];
st[j]=st[j+1];
st[j+1] =temp;
}
printf("The original message in alphabetical order are ");
printf("%s",st);
return 0;
}