Develop a program that performs simple cryptography. The program will allow
the user to enter a string and a cryptographic key, and the program will then encrypt the string using the key and send the output of the encryption to a f\ile.
This is what I have so far
#include <iostream>
#include<string>
using namespace std;
class Message
{
private:
string content;
int location;
public:
Message() : content(""), location(0) {};
Message(string s) : content(s), location(0) {};
string print() const;
void addToContent(string s);
};
string Message::print() const
{
return(content);
}
void Message::addToContent(string s)
{
content.append(s);
}
int main ()
{
string input;
cout << "enter some text: ";
getline(cin, input);
Message rect(input);
cout << "\nText was: " << rect.print() << endl;
return 0;
}
Class message
String content
Int location
1st constructor no arguments and initialize content to null string and location to 0.
2nd constructor takes string as argument and initializes content to the string that is its argument and location to 0.
Void print const() = prints out values of the data member content
Void addtocontent( string next); adds the string next to the data member content
Char getnextchar() returns character fom content first time getnextchar called returns first character from content 2nd time it returns 2nd character form c\
ontent…
Bool empty() returns true if you have read to the end of the string then next character to read will be the null character.
Class Caesar
Int shift;
1st constructor takes no arguments.
2nd constructor takes int as an argument and sets shift to the value of the int.
Void setshift has int as argument and sets shift to value of that argument.
Void encrypt takes character c as an argument and returns a character e
Void encrypt takes character c as an argument and returns a character encrypt applies Caesar cipher to its argument performs a static cast on c to make it i\
nto an integer adds shift to the integere applying modulus arithmetic shift of 2 to letter z will give b and then casts result back to character.
Class filehandlechar
Data member of type fstream
Constructor that opens the file output.txt for output using ios::app so that each time the file is used 1new data gets added to the end of the file
Dtor that closes the file outpt.txt
Void passtofile takes character as ana argument and writes that character to the file output.txt.
Class Encryption
Data member type Caesar
Data member type message
Data member type filehandlechar
Vois encryptthisstring takes string and an integer as its input and uses these along with the methods from Caesar and message to encrypt the string by shift\
ing the characters the amount of the integer
Int main()
Class Message
mymes
I really need to get the framework on it
I can figure out the rest.
Thanks
Related posts:








1 response so far ↓
1 dhvrm // Apr 14, 2008
So what, exactly, is your question?
Leave a Comment