
Instructions
Your job is to write a program to encrypt outgoing messages and decrypt incoming messages using a Vigenere Cypher.
In this assignment, you will parse a string of words from a file into tokens using the strtok_s command with pointers and then use the Vigenere Cypher
Before you can perform any encryption/decryption activities, the first step is to read in messages from a file and parse the messages into individual words.
The Program: Setting up classes and understanding tokenization
The first step in encrypting/decrypting messages is to parse the messages into words before applying the encryption/decryption algorithms to them. This parsing process is called “tokenization.”
Read the contents of a file into this array using the getline command.
The objective of this assignment is to demonstrate the use of pointers in a program utilizing c-strings and tokenization. The use of pointers is foundational in C++. This program provides an exercise in using pointers, passing them into functions, using them as return data types, and leveraging them in traversing arrays
Instructions
Since many of you are studying the field of Cyber Security, you may find this assignment to be especially interesting.
Your job is to write a program to encrypt outgoing messages and decrypt incoming messages using a Vigenere Cypher.
In this assignment, you will parse a string of words from a file into tokens using the strtok_s command with pointers and then use the Vigenere Cypher algorithm to encrypt and decrypt the parsed words.
Before you can perform any encryption/decryption activities, the first step is to read in messages from a file and parse the messages into individual words.
The first step in encrypting/decrypting messages is to parse the messages into words before applying the encryption/decryption algorithms to them. This parsing process is called “tokenization.”
Tokenization:
The process of parsing sentences into words is called tokenization. To tokenize a sentence into words, use the C++ function strtok_s. [Note: do not try to use the C++ strtok function because it has been deemed unsafe and has therefore been deprecated.]
In your “client” code (i.e. the file that contains your main function), you will need to declare a character array that will hold 1000 characters.
Read the contents of a file into this array using the getline command. To view a discussion on how to use getline with a file object, see this link:
There should be two classes in your program: Vigenere and Message.
Vigenere contains the encryption key and the logic for encrypting and decrypting individual words.
Message contains a
Vigenere Class
Data Member: string key
Functions: Vigenere() ßconstructor
void setKey(string k)
string getKey()
string toUpperCase(string k)
string encrypt(string word)
string decrypt(string word)
The Vigenere class should store an encryption key in a data member called “key.”
The class should have a one-argument constructor that receives a string that represents the encryption key. The encryption key must be in all capital letters for the encryption and decryption algorithms to work. Therefore, before setting the encryption key’s value, it should first be converted entirely to upper case. Do this in your toUpperCase function.
There should be two classes in your program: Vigenere and Message.
Vigenere contains the encryption key and the logic for encrypting and decrypting individual words.
Message contains a vector of words that have been encrypted or decrypted and the logic for calling the functions in the Vigenere class to encrypt or decrypt a word. The Message class serves as a middle-man between your client code and the Vigenere class and holds the encrypted/decrypted results in a vector.
Class Construction: Details
Vigenere Class
Data Member: string key
Functions: Vigenere() ßconstructor
void setKey(string k)
string getKey()
string toUpperCase(string k)
string encrypt(string word)
string decrypt(string word)
The Vigenere class should store an encryption key in a data member called “key.”
The class should have a one-argument constructor that receives a string that represents the encryption key. The encryption key must be in all capital letters for the encryption and decryption algorithms to work. Therefore, before setting the encryption key’s value, it should first be converted entirely to upper case. Do this in your toUpperCase function.

![Option 2 – Decrypt file
When the user selects option 2, he or she should immediately be prompted to enter the
name of the file to be decrypted: [Note that the file name can contain spaces.]
Enter the name of the file to decrypt: The Lords Prayer (Encrypted).txt
Your program should open the file and read its contents into a character array using the getline
function. As soon as the file's contents have been read into the character array, main() should
print the contents of the array to the screen.
HBZ YHBZGR POQUJ TYB BU ALINGN AHTDQWRE UL MOG GHUW MOG DPVYFOZ WUW MOG PPTD UL WV
W BU XHZLJ TZ BA BZ BU ALINGN ZPDW NZ MOQK WHG HBZ WHQDA UYMSF TUL YVZYKVR NZ HBZ
MYMKRAFTIS TZ PL YVZYKVR MOME MOIL MYMKRAFT TNIAPSG NZ TUL ELIV NZ GVB BUBG MLUHVAG
JSN UBB WLTAXEE NZ YYWE XCQD YVZ MOQFG BZ MOM DPVYFOZ MOM IVEWT TUL MOM ZSWJA YVZ X
CMJ TUL XCMJ TTME
Next, using the strtok_s function as described above, tokenize the entire message into separate
words. As each word is tokenized, call the decryptWord function in the Message class (using
the Message object to invoke the function and passing in each token as an argument ONE AT A
TIME).
The decryptWord function in the Message class should receive the token as a char* data type
and immediately cast it into a string variable. It should then pass this string into the decrypt
function in the Vigenere class using the Vigenere object that is a data member in the Message
class. Once the word is decrypted, the decryptWord function in the Message class should push
the decrypted word onto the vector of words in the Message class.
This process is repeated until the entire file's contents have been tokenized and decrypted.
Once the entire file has been tokenized and its decrypted words have been stored in the vector of
words in the Message class, main() should call the function in the Message class to create a new
file that contains the decrypted words. Therefore, the user must next be prompted to enter the
name of the file in which the decrypted data will be stored.
The program wil1 then create a new file based on the name that the user entered, and that file will
contain the contents of the words vector in the Message class. Recall that this vector contains
the words that are now decrypted. Therefore, main) should call the showWords function in the
Message class to print the contents of the words vector to the screen and then call the makeFile
function in the Message class to create the file and print the contents of the vector to the file.
After the file is created and its contents displayed to the screen, the Main Menu should be
redisplayed.](https://content.bartleby.com/qna-images/question/c15a87b4-2574-416f-9928-ee42886c4828/10d386e4-341f-4dd9-9c83-10b529e9f563/celiudb_thumbnail.jpeg)

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 12 images

- In C write a program that takes a file name and two strings as command line arguments, and writes the longer of the two strings to the file with the given name. If the given strings are the same length, write the first string given to the file. If the user does not provide the correct number of command line arguments, print an error message and exit the program with a non-zero exit code.arrow_forwardSimple python code Make this code batch-orientedarrow_forwardPython S3 Get File In the Python file, write a program to get all the files from a public S3 bucket named coderbytechallengesandbox. In there there might be multiple files, but your program should find the file with the prefix and cb - then output the full name of the file. You should use the boto3 module to solve this challenge. You do not need any access keys to access the bucket because it is public. This post might help you with how to access the bucket. Example Output ob name.txt Browse Resources Search for any help or documentation you might need for this problem. For exampler array indexing, Ruby hash tables, etc.arrow_forward
- python function that creates and saves data in a file. the saved data represents exam grades. in the function , you will create n random numbers in the range 1-100, where n is the number of students. The function can be called as follows: createFile(filename, n) main function, in which the user inputs the file name and the number of students, then the main calls function createfile. the main should preform validation for n (should be > 0), and the filename(should end with .txt)arrow_forwardcreateDatabaseOfProfiles(String filename) This method creates and populates the database array with the profiles from the input file (profile.txt) filename parameter. Each profile includes a persons' name and two DNA sequences. 1. Reads the number of profiles from the input file AND create the database array to hold that number profiles. 2. Reads the profiles from the input file. 3. For each person in the file 1. creates a Profile object with the information from file (see input file format below). 2. insert the newly created profile into the next position in the database array (instance variable).arrow_forwardIn C++, how do you encrypt one character in a file read into the code?arrow_forward
- Python 3 Given that a variable named pathName contains a string describing a directory path, write a single Python statement that will store the names of all files and subdirectories in that path in a List structure named contents. DO NOT traverse the path/directory. You are only interested in the immediate path and its contents. You may assume that any necessary import statements already exist.arrow_forwardPls help ASAParrow_forwardWhat happens if you enter a string greater than eight characters? How can a buffer overflow be avoided?arrow_forward
- <<Write in Java>> - Challenge 7 File encryption is the science of writing the contents of a file in a secret code. Your encryption program should work like a filter, reading the contents of one file, modifying the data into a code, and then writing the coded contents out to a second file. The second file will be a version of the first file, but written in a secret code. Although there are complex encryption techniques, you should come up with a simple one of your own. For example, you could read the first file one character at a time, and add 10 to the character code of each character before it is written to the second file. - Challenge 8 Write a program that decrypts the file produced by the program in Programming Challenge 7. The decryption program should read the contents of the coded file, restore the data to its original state, and write it to another filearrow_forwardThis is phython not Java Lab: Write a file copying program. The program asks for the name of the file to copy from (source file) and the name of the file to copy to (destination file). The program opens the source file for reading and the destination file for writing. As the program reads each line from the source file and it writes the line to the destination file. When every line from the source file has been written to the destination file, it close both files and print “Copy is successful.” In the sample run, “add.py” is the source file and “add-copy.py” is the destination file. Note that both “add-copy.py” is identical to “add.py” because “add-copy.py” is a copy of “add.py”. Sample run: Enter file to copy from: add.py Enter file to copy to : add-copy.py Copy is successful. Source file: add.py print("This program adds two numbers") a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) print(f"{a} + {b} = {a+b}") Destination…arrow_forwardWhen a file has an index directory, it means that the file may be randomly accessed.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





