| | |
String Encryption Challenge Help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2009
Posts: 15
Reputation:
Solved Threads: 0
I am having an extremely difficult time with this programming challenge I have to do. I have no idea where to begin on this. I am a beginning programmer (obvious I know), and here are my instructions for the challenge:
"Write a class EncryptableString that is derived from the STL string class. The EncryptableString class adds a member function
void encrypt( )
That encrypts the string contained in the object by replacing each letter with its successor in the ASCII ordering. For example, the string baa would be encrypted to cbb. Assume that all characters that are part of an EncryptableString object are letters a..z and A...Z, and that the successor of z is a and the successor of Z is A. Test your class with a program that asks the user to enter strings that are then encrypted and printed.
If someone can maybe lay these instructions out in a more clear and simplified form so I can possibly comprehend it better. I am quite confused on how this should be done.
This is what tiny little beginning I have, hopefully it's right. I still need a lot of help on laying out where the stuff should go, and then of course actually doing it. Any help would be greatly appreciated.
EncryptableString.h
EncryptableString.cpp
EncryptString.cpp
"Write a class EncryptableString that is derived from the STL string class. The EncryptableString class adds a member function
void encrypt( )
That encrypts the string contained in the object by replacing each letter with its successor in the ASCII ordering. For example, the string baa would be encrypted to cbb. Assume that all characters that are part of an EncryptableString object are letters a..z and A...Z, and that the successor of z is a and the successor of Z is A. Test your class with a program that asks the user to enter strings that are then encrypted and printed.
If someone can maybe lay these instructions out in a more clear and simplified form so I can possibly comprehend it better. I am quite confused on how this should be done.
This is what tiny little beginning I have, hopefully it's right. I still need a lot of help on laying out where the stuff should go, and then of course actually doing it. Any help would be greatly appreciated.
EncryptableString.h
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <string> using namespace std; class EncryptableString { public: EncryptableString(); void encrypt(); };
EncryptableString.cpp
C++ Syntax (Toggle Plain Text)
#include "EncryptableString.h" #include <iostream> #include <string> using namespace std; void EncryptableString::encrypt() { // Encryption Code Here }
EncryptString.cpp
C++ Syntax (Toggle Plain Text)
#include "EncryptableString.h" #include <iostream> #include <string> using namespace std; int main() { EncryptableString.encrypt(); cin.get(); return 0; }
I think those instructions are pretty clear.
Create a class, that is derived from the string class. You will have to create your own constructor(s), the encryption method, and ideally input and output methods. See below for a general framework
Create a class, that is derived from the string class. You will have to create your own constructor(s), the encryption method, and ideally input and output methods. See below for a general framework
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <string> using namespace std; class myString: public string { private: public: myString( ); myString( string source ); void modify( ); string theString; //should be private, and need to include input output methods }; myString::myString( ) { theString = ""; } myString::myString(string source ) { theString = source; } void myString::modify( ) { theString[0] = 'A'; } int main() { myString s1; myString s2( "Hello, World" ); cout << s1.theString << endl << s2.theString << endl << endl; s2.modify( ); cout << s2.theString << endl; return 0; }
Everyone's gotta believe in something. I believe I'll have another drink.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
You can use this to encrypt your string.
I made a class that has a private variable content and has two public functions: print() and encrypt().
Based on some of your start code you showed I have a feeling you are going to run into a few problems while doing this project.
EncryptableString.encrypt() means nothing because it is a variable type not a variable its self.
Coming across this thread made me wonder how to output a variable within a class without having to call a function. I made a new thread for that but not knowing how to do that forced me to use a print() function, which I think is messy unless this is going to be a closed source submission.
C++ Syntax (Toggle Plain Text)
void EncryptableString::encrypt() { for( int i = 0; i < content.length(); i++ ) { if( (content[i] >= 'a' && content[i] < 'z') || (content[i] >= 'A' && content[i] < 'Z')) { content[i] += 1; } else if( content[i] == 'z' || content[i] == 'Z' ) { content[i] -= 25; } } }
Based on some of your start code you showed I have a feeling you are going to run into a few problems while doing this project.
C++ Syntax (Toggle Plain Text)
#include "EncryptableString.h" #include <iostream> #include <string> using namespace std; int main() { EncryptableString.encrypt(); cin.get(); return 0; }
EncryptableString.encrypt() means nothing because it is a variable type not a variable its self.
Coming across this thread made me wonder how to output a variable within a class without having to call a function. I made a new thread for that but not knowing how to do that forced me to use a print() function, which I think is messy unless this is going to be a closed source submission.
I believe your homework is complete. All you have to do know is put those two in one and study it well, understanding how to program.
Fundamental law of life:
do{ ThingsToDo+=me.CompleteTask(ThingsToDo); }while(ThingsToDo); Die(me);
Law of the Spirit:
do{ Rebuke(me); }while(!me.Repented); LiveEternal(me);
PM me to know more why i wrote this or what it means.
do{ ThingsToDo+=me.CompleteTask(ThingsToDo); }while(ThingsToDo); Die(me);
Law of the Spirit:
do{ Rebuke(me); }while(!me.Repented); LiveEternal(me);
PM me to know more why i wrote this or what it means.
![]() |
Similar Threads
- AES Encryption Logic (Java)
- base64 encryption (PHP)
- Interesting String Encryption (C++)
- Encrypt a "string" (C++)
- Validating radio button selection for login redirect (JavaScript / DHTML / AJAX)
- Daniweb encryption challenge (Network Security)
Other Threads in the C++ Forum
- Previous Thread: Prime numbers and the for loop
- Next Thread: Need help with 2 functions
| Thread Tools | Search this Thread |
Tag cloud for challenge, encryption, string
2d access add animation array assembly assign binary blackmail block browser buttons c# c++ calculator challenge char character compression convert count crack crime data date datetime decryption dell drawing dynamic ect email encryption file filename firefox format fstream ftp function gdi+ getline government hardware ifstream input int java kioti16 kmip laptop line list listbox london loop memory method microsoft mobile namevaluepairs news opensource parse parsing password path pattern perl php program protection python recursion regex remove reverse rotation rsa saving security single size slicenotation softwaredevelopment sql string subscript sun superscript survey taxi timer unicode user validation virus webmail word year







