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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started