Question

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 is supposed to return the character that is in the shifted array at the index (aka what is the character at index z)

**The length of the code is unknown (but can be figured out using '\0' character)

**Assume that strings of 27 (26 letters in the alphabet and the space "_") characters can be called, and that all the characters are unique (never repeated).

PLEASE COMMENT ON YOUR CODE EXPLAINING WHAT WAS DONE

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

SOLUTION:-

// SIMPLE C PROGRAM TO ENCRYPT AND DECRY P T A STRING //

/*

#include<stdio.h>

int main( )

{

int i, x;

char s t r[100];

print f("\n Please enter a string :\t");

gets(s t r);

print f("\n Please choose following options:\n");

print f("1= Encrypt the string.\n");

print f("2= Decry pt the string .\n");

scan f("%d" ,&x);

//using switch case statements

switch(x)

{

case 1:

for(i = 0; (i< 100 && s t r[i] !='\0');i++)

s t r[i]=s t r[i] +3;

// the key for encryption

print f(" \n decry pt ed string: %s \n",s t r);

break;

default:

print f( " \n Error \n");

}

return 0;

}

*/

Add a comment
Know the answer?
Add Answer to:
C PROGRAMMING Implement a function (using only #include library) that can encrypt/decrypt with a substitution cipher....
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];                                                      ...

  • Using a substitution cipher that skips by 7 characters, encrypt the message COMPUTERSCIENCE4ALL. For the input...

    Using a substitution cipher that skips by 7 characters, encrypt the message COMPUTERSCIENCE4ALL. For the input alphabet use 26 uppercase letters followed by 10 digits numbered 0 through 9. I have encrypted an English phrase using a substitution cipher that has an input alphabet of 26 uppercase letters. My cipher has skipped by N letters. You may assume that the most common letters in the English language are E T A O I N Sentence: LJWRPDNBBCQNARPQCJWBNA

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

  • Write the programming C please, not C++. The main function should be to find the offset...

    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. 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...

  • Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is...

    Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is to create a program to encode files and strings using the caesar cipher encoding method. Information about the caesar method can be found at http://www.braingle.com/brainteasers/codes/caesar.php.   Note: the standard caesar cipher uses an offset of 3. We are going to use a user supplied string to calculate an offset. See below for details on how to calculate this offset from this string. First open caesar.cpp...

  • C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt...

    C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...

  • C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want...

    C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...

  • Cryptography, the study of secret writing, has been around for a very long time, from simplistic...

    Cryptography, the study of secret writing, has been around for a very long time, from simplistic techniques to sophisticated mathematical techniques. No matter what the form however, there are some underlying things that must be done – encrypt the message and decrypt the encoded message. One of the earliest and simplest methods ever used to encrypt and decrypt messages is called the Caesar cipher method, used by Julius Caesar during the Gallic war. According to this method, letters of the...

  • C Programming - RSA encryption Hi there, I'm struggling with writing a C program to encrypt and decrypt a string usi...

    C Programming - RSA encryption Hi there, I'm struggling with writing a C program to encrypt and decrypt a string using the RSA algorithm (C90 language only). It can contain ONLY the following libraries: stdio, stdlib, math and string. I want to use the following function prototypes to try and implement things: /*Check whether a given number is prime or not*/ int checkPrime(int n) /*to find gcd*/ int gcd(int a, int h) void Encrypt(); void Decrypt(); int getPublicKeys(); int getPrivateKeys();...

  • Java programming problem. I've managed to get through the basic level of encryption, but the advanced...

    Java programming problem. I've managed to get through the basic level of encryption, but the advanced and military grade sections are beyond me. If someone can show me what the hell this code is supposed to look like I'd greatly appreciate it. In other words I need to write a code that can decrypt a string message by the following parameters. Basic: Using Caesar Cipher with a static shift of 1-25. This is easy to decrypt as there are only...

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