Question

In: Computer Science

The mathematical expression of the encryption and decryption process of a Caesar cipher algorithm is expressed...

  1. The mathematical expression of the encryption and decryption process of a Caesar cipher algorithm is expressed respectively as:

c=Ep, k=p+k%26                                                                                                                         (1)

p=Dc,k=c-k%26                                                                                                                         (2)

Please do the following:

  1. Write at least two paragraphs to explain the principle of operation of the algorithm. For a full credit, your explanation must show the architectural diagram of the encryption and decryption process.
  2. Write a program to implement the Caesar algorithm
    1. Code must have two functions; encryption and decryption
    2. Test your codes with p as ‘cryptography’ using k =5

Solutions

Expert Solution

1 )


II) C program for implementing Caesar cipher algorithm:

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

char data[50], temp;
int key, count;

void getmessage()
{
printf("Enter a String:\t");
scanf("%[^\n]s", data);
}

void key_input()
{
printf("Enter a Key:\t");
scanf("%d", &key);
}

void encryption() /* function for encryption */
{
for(count = 0; data[count] != '\0'; count++)
{
temp = data[count];
if(temp >= 'a' && temp <= 'z')
{
temp = temp + key;
if(temp > 'z')
{
temp = temp - 'z' + 'a' - 1;
}
data[count] = temp;
}
else if(temp >= 'A' && temp <= 'Z')
{
temp = temp + key;
if(temp > 'Z')
{
temp = temp - 'Z' + 'A' - 1;
}
data[count] = temp;
}
}
printf("\nEncrypted Message:\t%s\n", data);
}

void decryption() /* function for decryption */
{
for(count = 0; data[count] != '\0'; count++)
{
temp = data[count];
if(temp >= 'a' && temp <= 'z')
{
temp = temp - key;
if(temp < 'a')
{
temp = temp + 'z' - 'a' + 1;
}
data[count] = temp;
}
else if(temp >= 'A' && temp <= 'Z')
{
temp = temp - key;
if(temp < 'A')
{
temp = temp + 'Z' - 'A' + 1;
}
data[count] = temp;
}
}
printf("\nDecrypted Message:\t%s\n", data);
}

int main()
{
int choice;
getmessage();
key_input();
while(1)
{
printf("\n1. Encryption\n2. Decryption\n3. Exit\n");
printf("\nEnter You Choice:\t");
scanf("%d", &choice);
switch(choice)
{
case 1: encryption();
break;
case 2: decryption();
break;
case 3: exit(0);
default: printf("\nPlease select a correct option:\n");
}
}
printf("\n");
return 0;
}

output :
Enter a String:
' cryptography '
Enter a Key :
5
1.Encryption
2.Decryption
3.Exit
Enter Your Choice:
1
Encrypted Message: hwduytlwfumd

1.Encryption
2.Decryption
3.Exit
Enter Your Choice:
2
Decrypted Message : cryptography

and last i am uploading one more picture ,how to find cipher test using algorithm


Related Solutions

In C++, write a program to implement the Caesar Cipher for both encryption and decryption. The...
In C++, write a program to implement the Caesar Cipher for both encryption and decryption. The program should be able to handle different keys by deciding the key at run time. Thank you :)
use C++ You will implement the following encryption and decryption functions/programs for the Caesar cipher. Provide...
use C++ You will implement the following encryption and decryption functions/programs for the Caesar cipher. Provide the following inputs and outputs for each function/program: EncryptCaesar Two inputs: A string of the plaintext to encrypt A key (a number) ▪ For the Caesar cipher: This will indicate how many characters to shift (e.g. for a key=3, A=>D, B=>E, ..., X=>A, Y=>B, Z=>C). Note that the shift is circular. One output: ◦ A string of the ciphertext or codeword DecryptCaesar Two inputs:...
In cryptography, Caesar cipher is one of the simplest encryption techniques. The key idea of this...
In cryptography, Caesar cipher is one of the simplest encryption techniques. The key idea of this method is to replace each plaintext letter with one fixed number of places down the alphabet. Below is an example with a shift of three: Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz Cipher: DEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABC To cipher a string, ‘A’ is replaced by ‘D’, ‘B’ is substituted by ‘E’, and so on. To decode a string, ‘A’ is replaced by ‘x’, etc. By using python with vs code: Write a...
The Vigenère Cipher is an encryption algorithm that combines the use of a keyword with the...
The Vigenère Cipher is an encryption algorithm that combines the use of a keyword with the message to be encrypted. A tableau is provided that shows an encrypted character for each combination of characters in the message and the keyword. Using the Vigenère Tableau encryption scheme with a keyword of KEYWORD, encrypt the following message: IS INFORMATION SECURITY ESSENTIAL After encrypting the message, decrypt the following message, using KEYWORD as the keyword: YRJUW WWRIG JTFUW ERECE LCMKL CIWKR R For...
Problem 2: Caesar Cipher Decryption] Write a python method that takes two parameters: A parameter of...
Problem 2: Caesar Cipher Decryption] Write a python method that takes two parameters: A parameter of type str and a parameter of type int. The first parameter is the plaintext message, and the second parameter is the encryption key. The method strictly does the following tasks: a. Reverse the operations performed by the encryption method to obtain the plaintext message. The method’s header is as follows: def casesardecryption(s, key):
Caesar Cipher Encryption] Write a method that takes two parameters: A parameter of type str and...
Caesar Cipher Encryption] Write a method that takes two parameters: A parameter of type str and a parameter of type int. The first parameter is the plaintext message, and the second parameter is the encryption key. The method strictly does the following tasks: a. Convert the string into a list (let us refer to it as lista). An element in the generated list is the position of the corresponding letter in the parameter string in the English alphabet. Example: ‘C’...
In the caeser cipher encryption and decryption program below, what do the two lines if(ch >...
In the caeser cipher encryption and decryption program below, what do the two lines if(ch > 'z'){ ch = ch - 'z' + 'a' - 1; } if(ch < 'a'){ ch = ch + 'z' - 'a' + 1; } mean??? I understand that it has something to do with ASCII characters and makes sure that if the encryption/decryption character is more than "z", then it would loop back to "a" instead of outputting a charcter like "{" . I...
The prompt is using Python:  Write a 3 rail transposition encryption algorithm, and a corresponding decryption algorithm....
The prompt is using Python:  Write a 3 rail transposition encryption algorithm, and a corresponding decryption algorithm. Implement these two algorithms in their own function. Now write a testing function that demonstrates your algorithms work for all interesting cases!
Alice is sending message “HIDE” to Bob. Perform encryption and decryption using RSA algorithm, with the...
Alice is sending message “HIDE” to Bob. Perform encryption and decryption using RSA algorithm, with the following information: parameters p=11,q=5, e=7 Present all the information that you will need to encrypt and decrypt only the first letter from text
In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or...
In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. Given an arbitrary cipher text file, you need to write a C++ program to find out the value of the shift going down the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT