![]() |
|
#1
|
|||
|
|||
encryption stuffHi, I was wondering if you could help…
I need to write a program to carry out encryption using a SSC. It needs to prompt the user for 3 filenames; key, plaintext, and cipertext files, then open the files. It needs to read the key into array Key, while (plaintextchar read from plaintextfile is not equal to EOF) convert char into ciphertextchar using key, write ciphertextchar to ciphertext file, and finally close files. I have this already… it reads the key from a text file, and stores it in an array,the it prints the contents on screen: CPP / C++ / C Code:
Last edited by dsmith : 10-Apr-2005 at 06:41.
Reason: Please use [c] & [/c] when posting C code
|
|||
|
#2
|
||||
|
||||
|
Warning: Do not use exit() unless you are using C and ONLY C. If you use C++ classes or any libraries that include classes, you must NOT use exit().
Ok, so what are you having trouble with? __________________
-Aaron |
|
#3
|
|||
|
|||
|
Well I could kind of get the prompts for the three files working (though I posted the code here without because I didn't have it completely sorted out). I screwed up trying to open them all and storing them in arrays. The files are ...one for the key - so A is W, B is E, etc... one for plaintext (like the english alphabet), and one for cipertext (what you want the letters to be substituted for, so W as A, etc).
|
|
#4
|
|||
|
|||
|
if you can use C++, I would suggest using a map, or two. maps are like arrays, except that the key type can be anything you want instead of just int. so if you declared a
CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
|
|
#5
|
||||
|
||||
|
I think that's too complicated for him. Seems like this is a first programming course to me. So, you are having trouble opening the files and sorting their data into arrays? Here's how it should be done...
CPP / C++ / C Code:
So, the first thing I would do is write a function that reads data from a file and sorts it into an array, given the name of the file and the size of the array as parameters. Once you've got that done, the rest of the work lies in what to do with the data in the arrays. If you are having trouble storing data from the file into the array, here's a quick example of how it might be done. CPP / C++ / C Code:
By the way, ubergeek, what the heck kind of identifier is m_strb? I hope you don't write all of your identifiers like that! __________________
-Aaron |
|
#6
|
||||
|
||||
|
Quote:
Quote:
The first thing I'd do is write functions to read the data from the files, one function per file. Write them one at a time. Print the data as it's read to verify proper reading. When working, remove the print section. The second thing I'd do is write the output function, writing all the data arrays and make sure the arrays are still displayed properly. The third thing is to write the encryption function and call it between your input and output functions. Once the program is working, the last thing is to remove the unnessesary output. __________________
The 3 Laws of the Procrastination Society: 1) Never do today that which can be put off until tomorrow 2) Tomorrow never comes |
|
#7
|
||||
|
||||
|
If the data is stored into each array exactly the same way for all 3 functions, then isn't it kind of silly to have 3 functions instead of 1?
__________________
-Aaron |
|
#8
|
||||
|
||||
|
Quote:
__________________
The 3 Laws of the Procrastination Society: 1) Never do today that which can be put off until tomorrow 2) Tomorrow never comes |
|
#9
|
|||
|
|||
|
Quote:
|
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is the best place to buy computer stuff? | Bulkhead | Computer Hardware Forum | 21 | 16-Jun-2005 06:50 |
| need help with encryption | bobthesled | C Programming Language | 9 | 15-Feb-2005 11:24 |
| .o compile UNIX stuff ... help please! | crq | C++ Forum | 5 | 28-Jan-2005 07:43 |
| Help with binary files (encryption?) | pablowablo | C++ Forum | 6 | 28-Apr-2004 22:47 |
| RE: Sessions stuff for a confused programmer | Dagma20 | MySQL / PHP Forum | 1 | 19-Mar-2004 05:10 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The