Question

In cryptography, a Caesar Cipher 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. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence. wiki/Caesar cipher A B C D E F A BCD E F In a Caesar Cipher, the encryption is performed against a key string, which is often just the 26 letters of the alphabet. An offset value is defined that consists of a positive or negative integer The plaintext (the normal text is encrypted, one letter at a time, by using that offset value in the following way: (a) the index position within the key string of the letter to be encrypted is determined, (b) the offset value is applied to that index in order to obtain a new index within the key string, (c) the character at the new index is written as the cipher text. For a simple example, lets assume the key string consists of the 26 letters of the alphabet plus a Space S1325-Introduction to Programming page: 2 Here we have the 26 letters of the English alphabet plus a space with their index positions listed above. To simplify, well stick with all caps for the moment.) We want to encrypt the phrase I LOVE TO FLY using an offset off +5. We get the following Plain text: I LOVE TO FLY Cipher text: NEQT JEYTEKQC Note that I has an index of 8. When we add 5 we get an index of 13, which corresponds to the letter N. Similarly, the letter Y has an index of 24. When we add 5 we get 29, but since that index doesnt exist within the array, we wrap around and replace the Y with a C To decrypt a message, we apply the offset value in reverse. If the offset were added to produce the cipher text, then it should be subtracted to reconstitute the plaintext.

Write the programming C please, not C++. The main function should be to find the offset value of the ciper text "wPL2KLK9PWWZ7K3ST24KZYKfPMKJ4SKLYOKRP4KFKP842LK0ZTY43 " and decrypt it.

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

#include<stdio.h>
#include<string.h>
int decrypt(char* text, int s)
{
    int i; char result[128];
    for(i=0; i<strlen(text); i++)
    {
         result[i] = text[i]-s;
    }
    printf("Decrypt: %s\n", result);
}
void encrypt(char text[], int s)
{
   char result[128];
   int i,length=0;
  
  
   for (i=0; i<strlen(text);i++)
   {
       // Encrypt Uppercase letters
       if (isupper(text[i]))
           result[i] = (text[i]+s-65)%26 +65;
            // Encrypt Lowercase letters
        else
           result[i]=(text[i]+s-97)%26 +97;
        }
    printf("Cipher: %s\n",result);
   decrypt(result, s);
}

int main()
{
   char text[128]="I LOVE FLY";
   int s =5;
   printf("Text: %s\n",text);
   encrypt(text, s);
   return 0;
}

sh-4.25 gcc -o maïn·c sh-4.2$ main Text: I LOVE FLY Cipher: NYQTAJYKQD Decrypt: ITLO ETFL? sh-4.2$

sh-4.2$ mairn Text: abcdef Cipher: fghijk Decrypt: abcdef sh-4.2$

Add a comment
Know the answer?
Add Answer to:
Write the programming C please, not C++. The main function should be to find the offset...
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
  • 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, and decrypt the...

  • 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];                                                      ...

  • This is Crypto Manager blank public class CryptoManager { private static final char LOWER_BOUND = '...

    This is Crypto Manager blank public class CryptoManager { private static final char LOWER_BOUND = ' '; private static final char UPPER_BOUND = '_'; private static final int RANGE = UPPER_BOUND - LOWER_BOUND + 1; /** * This method determines if a string is within the allowable bounds of ASCII codes * according to the LOWER_BOUND and UPPER_BOUND characters * @param plainText a string to be encrypted, if it is within the allowable bounds * @return true if all characters...

  • C PROGRAMMING Implement a function (using only #include library) that can encrypt/decrypt with a substitution cipher....

    C PROGRAMMING Implement a function (using only #include library) that can encrypt/decrypt with a substitution cipher. cipher_sub (a, b, c, d) a is the string that has the data that will be encrypted or decrypted b is the string that has the result of the encrypt/decrypt c is the code string used for our substitution cipher (27 entries plus '\0' character) d is an integer that will pass two constants defined as ENC (encrypt) or DEC (decrypt) --> The function...

  • Caesar Cipher v3 Decription Description A Caesar cipher is one of the first and most simple...

    Caesar Cipher v3 Decription Description A Caesar cipher is one of the first and most simple encryption methods. It works by shifting all letters in the original message (plaintext) by a certain fixed amount (the amounts represents the encryption key). The resulting encoded text is called ciphertext. Example Key (Shift): 3 Plaintext: Abc Ciphertext: Def Task Your goal is to implement a Caesar cipher program that receives the key and an encrypted paragraph (with uppercase and lowercase letters, punctuations, and...

  • JAVA PROJECT Part 1 - Normalize Text The first thing we will do is normalize the...

    JAVA PROJECT Part 1 - Normalize Text The first thing we will do is normalize the input message so that it’s easier to work with. Write a method called normalizeText which does the following: Removes all the spaces from your text Remove any punctuation (. , : ; ’ ” ! ? ( ) ) Turn all lower-case letters into upper-case letters Return the result. The call normalizeText(“This is some \“really\” great. (Text)!?”) should return “THISISSOMEREALLYGREATTEXT” Part 2 - Obfuscation...

  • Please help me write this Java program. I had posted this question before, but got an...

    Please help me write this Java program. I had posted this question before, but got an answer that was totally wrong. We are using the latest version of Java8. Thank You! -------------------------------------------------------------------------------------- Write a Java program that can successfully DECRYPT a string inputted by the user which has been encrypted using a Caesar Cipher with a unknown shift value(key). You can use brute force to do a for loop through all the 26 shift values, however, your program should only...

  • do the following in python idle 3.5 or higher know nothing on this subject Eile Edit...

    do the following in python idle 3.5 or higher know nothing on this subject Eile Edit Yew Hbtory Bookmarks bols Help Microsoft Word-Situatio x S Female coaches: Why are. x a SakaieURI:csc 110 spri.. x O lab7-crypto-s17-labr-cry. x Writer The owing Code. x https sakai. 7-Cryptog rithms -10 28 /lab7-cryp 67k e a Search A Most visited e Getting started To decode an Affine cipher, we need to reverse the process. This is not a simple as reversing a Caesar...

  • Security is an important feature of information systems. Often, text is encrypted before being sent, and...

    Security is an important feature of information systems. Often, text is encrypted before being sent, and then decrypted upon receipt. We want to build a class (or several classes) encapsulating the concept of encryption. You will need to test that class with a client program where the main method is located. For this project, encrypting consists of translating each character into another character. For instance, if we consider the English alphabet, including characters a through z, each character is randomly...

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

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
Active Questions
ADVERTISEMENT