I have a school assignment in which asks me to create a program that does the following on encryption and decryption:
Write a program that encrypts and decrypts a text (string). The program reads a text into a character pointer: char * originaltext. Write a function that encrypts originaltext and store the encrypted text into: char * ciphertext. The encryption algorithm is replacing each character by a character having 10 added to its ASCII code. Write another function that decrypts ciphertext and store the result into: char * deciphertext. The decryption algorithm is replacing each character by a character having 10 subtracted from its ASCII code. Display the three strings originaltext, ciphertext,and deciphertext.
It then gives the following hints to start the program:
- Use malloc or calloc functions to allocate dynamically a memory space for strings.
- Assume that the text has a maximum of 100 characters.
- Donít forget to deallocate the memory using free function.
Could somebody help me to write the program, I'm really stuck and don't know how to start.