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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

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.

The encryptWord 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 encrypt
function in the Vigenere class using the Vigenere object that is a data member in the Message
class. Once the word is encrypted, the encryptWord function in the Message class should push
the encrypted word onto the vector of words in the Message class.
This process is repeated until the entire file's contents have been tokenized and encrypted.
Once the entire file has been tokenized and its encrypted 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 encrypted words. Therefore, the user must be prompted to enter the name
of the file in which the encrypted data will be stored:
A new file will be created that contains the encrypted message.
Please enter the name of the new file to create: The Lords Prayer (Encrypted).txt
The program will 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 encrypted. 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.
SC
After the file is created and its contents are displayed to the screen, the Main Menu should be
redisplayed.
The new file contains the following encrypted message.
HBZ YHBZGR POQUJ TYB BU ALINGN AHTDQWRE UL MOG GHUW MOG DPVYFOZ WUW MOG PPTD UL W
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 MLUHVA
JSN UBB WLTAXEE NZ YYWE XCQD YVZ MOQFG BZ MOM DPVYFOZ MOM IVEWT TUL MOM ZSWJA YVZ
CMJ TUL XCMJ TTME
Vigenere Cypher
Main Menu
1 - Encrypt File
2 - Decrypt File
3 - Quit
Selection:
Transcribed Image Text:The encryptWord 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 encrypt function in the Vigenere class using the Vigenere object that is a data member in the Message class. Once the word is encrypted, the encryptWord function in the Message class should push the encrypted word onto the vector of words in the Message class. This process is repeated until the entire file's contents have been tokenized and encrypted. Once the entire file has been tokenized and its encrypted 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 encrypted words. Therefore, the user must be prompted to enter the name of the file in which the encrypted data will be stored: A new file will be created that contains the encrypted message. Please enter the name of the new file to create: The Lords Prayer (Encrypted).txt The program will 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 encrypted. 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. SC After the file is created and its contents are displayed to the screen, the Main Menu should be redisplayed. The new file contains the following encrypted message. HBZ YHBZGR POQUJ TYB BU ALINGN AHTDQWRE UL MOG GHUW MOG DPVYFOZ WUW MOG PPTD UL W 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 MLUHVA JSN UBB WLTAXEE NZ YYWE XCQD YVZ MOQFG BZ MOM DPVYFOZ MOM IVEWT TUL MOM ZSWJA YVZ CMJ TUL XCMJ TTME Vigenere Cypher Main Menu 1 - Encrypt File 2 - Decrypt File 3 - Quit Selection:
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.
Transcribed Image Text: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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 12 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education