Question

. Please write a function that will do the following Decryption of a message encrypted with a substitution cipher given cipher text only without any key Please provide comments on each line of code ou...

.

Please write a function that will do the following

Decryption of a message encrypted with a substitution cipher given cipher text only without any key

Please provide comments on each line of code outlining what that line is doing.

Note: Only the Function is to be written, all user inputs i.e the text to be decrypted will be entered earlier in the program.

Code must be written in C and be able to be compiled using GCC

If any questions need to be asked before attempting please do so

0 0
Add a comment Improve this question Transcribed image text
Answer #1

void sub_decrypt()
{
printf("Enter a text to Decrypt substitution cipher (without substitutions/key): \n");   
                scanf(" %[^\n]s", text);      
                printf("\nDecrypted Text: ");
  
                for(n=0; text[n]!='\0'; n++)
                {
                     if(text[n] >= 'a' && text[n] <= 'z')
                     {
                        text[n] = text[n] - 32;
                     }
                    if(text[n] < 'A' || text[n] > 'Z')
                    {
                        printf("%c", text[n]);
                    }
          
                    for(i=0; i<26; i++)
                    {
                        if(substitution[i] >= 'a' && substitution[i] <= 'z')
                        {
                            substitution[i] = substitution[i] - 32;
                        }
                        if (text[n] == substitution[i])
                        {
                            printf("%c", ALPHABET[i]);
                        }
                    }
                }
return 0;
}

Add a comment
Know the answer?
Add Answer to:
. Please write a function that will do the following Decryption of a message encrypted with a substitution cipher given cipher text only without any key Please provide comments on each line of code ou...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need Help to Write a function in C that will Decrypt at least one word with a substitution cipher given cipher text an...

    I need Help to Write a function in C that will Decrypt at least one word with a substitution cipher given cipher text and key My Current Code is: void SubDecrypt(char *message, char *encryptKey) { int iteration; int iteration_Num_Two = 0; int letter; printf("Enter Encryption Key: \n");                                                           //Display the message to enter encryption key scanf("%s", encryptKey);                                                                   //Input the Encryption key for (iteration = 0; message[iteration] != '0'; iteration++)                               //loop will continue till message reaches to end { letter = message[iteration];                                                      ...

  • Question: Please Provide Comments on each Line of code explaining what the C Function is doing throughout the code. // Function used for substitution encryption                     void SubEncrypt(cha...

    Question: Please Provide Comments on each Line of code explaining what the C Function is doing throughout the code. // Function used for substitution encryption                     void SubEncrypt(char *message, char *encryptKey) { int iteration = 0; printf("Enter Aphabet Encryption Key: \n"); scanf("%s", encryptKey);    for (iteration = 0; iteration < strlen(message); iteration++) { char letter = message[iteration]; if (letter >= 'A' && letter <= 'Z') {    letter = encryptKey[letter - 'A']; } message[iteration] = letter; } printf("CipherText message: %s\n", message); } //_________________________________________________________________________________________________________________________________________________...

  • Decrypting the APCO cipher without the key. Decryption without the key is obviously a much more...

    Decrypting the APCO cipher without the key. Decryption without the key is obviously a much more difficult process. Indeed, the purpose of encryption is to make it as difficult as possible for anyone who does not know the key to read the plain text. We will be using an unsophisticated password cracking technique called a brute force attack. A brute force attack on the APCO cipher works by trying every possible four digit key (from 0000 to 9999) and keeping...

  • Help write down below program with C++ language!!! Please... The Cipher Program Requirements An interactive program...

    Help write down below program with C++ language!!! Please... The Cipher Program Requirements An interactive program is required that allows a user to encode text using any of three possible ciphers. The three ciphers you are to offer are: Caesar, Playfair and Columnar Transposition. • The program needs to loop, repeating to ask the user if they wish to play with Caesar, Playfair or Columnar Transposition until the user wishes to stop the program. •For encoding, the program needs to...

  • C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require...

    C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a file. The encryption method being used on the file is called a shift cipher (Info Here). I will provide you with a sample encrypted message, the offset, and the decrypted message for testing. For this project I will provide you main.cpp, ShiftCipher.h, and ShiftCipher.cpp....

  • ****************************************************************************************************************8 I want it same as the output and with details please and comments "For two...

    ****************************************************************************************************************8 I want it same as the output and with details please and comments "For two thousand years, codemakers have fought to preserve secrets while codebreakers have tried their best to reveal them." - taken from Code Book, The Evolution of Secrecy from Mary, Queen of Scots to Quantum Cryptography by Simon Singh. The idea for this machine problem came from this book.You will encrypt and decrypt some messages using a simplified version of a code in the book. The...

  • Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D....

    Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D. Decryption Implement two decryption functions corresponding to the above ciphers. When decrypting ciphertext, ensure that the produced decrypted string is equal to the original plaintext: decryptCaesar(ciphertext, rshift) == plaintext decryptVigenere(ciphertext, keyword) == plaintext Write a program decryption.cpp that uses the above functions to demonstrate encryption and decryption for both ciphers. It should first ask the user to input plaintext, then ask for a right...

  • This project will use The Vigenere Cipher to encrypt passwords. Simple letter substitution ciphers are ones...

    This project will use The Vigenere Cipher to encrypt passwords. Simple letter substitution ciphers are ones in which one letter is substituted for another. Although their output looks impossible to read, they are easy to break because the relative frequencies of English letters are known. The Vigenere cipher improves upon this. They require a key word and the plain text to be encrypted. Create a Java application that uses: decision constructs looping constructs basic operations on an ArrayList of objects...

  • You will be writing a simple Java program that implements an ancient form of encryption known...

    You will be writing a simple Java program that implements an ancient form of encryption known as a substitution cipher or a Caesar cipher (after Julius Caesar, who reportedly used it to send messages to his armies) or a shift cipher. In a Caesar cipher, the letters in a message are replaced by the letters of a "shifted" alphabet. So for example if we had a shift of 3 we might have the following replacements: Original alphabet: A B C...

  • Consider the following C++ program. It reads a sequence of strings from the user and uses...

    Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13 +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT