Question: Programming in C Encryption & Decryption Write a function encrypt that takes two strings s1 and s2 and an integer shift as parameters. Your function

Programming in C

Encryption & Decryption

Write a function encrypt that takes two strings s1 and s2 and an integer shift as parameters. Your function encrypts s1 and stores it in s2. The encryption is done by shifting each character shift number of places. For example if shift is 4, then every A in the s1 becomes E in s2, and B becomes F and so on. Z becomes the character Z + 4 which is ^ according to the ASCII table.

Write another similar function decrypt (that takes two strings s1 and s2 and an integer shift as parameters) and decrypts s1 by shifting its characters back shift places and storing it in s2.

Both functions should take s1 and s2 as char * as two parameters (pointer to char) plus the shift parameter as int.

Write a program encryption.c whose main procedure reads a sentence from the user and encrypts it then decrypts it. Specifically, your program should ask the user Enter the text to encrypt. Then, it asks Enter the shift amount. After calling encrypt(origText, encText, shift), the main procedure outputs Encrypted: followed by the encrypted string. Then, after calling decrypt(encText, decText, shift), the main procedure outputs Decrypted: followed by the decText string.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!