Hello to all programmers:
I have been working on the following program but I am encountering some difficulties any help whatsoever would be greatly appreciated.
My instructions are:
Write a c++ program,
1. Prompts the user for a choice of encrypt or decrypt, prompts for the input and output filenames
2. has a function for encryption
a. generates a random key
b. stores the key in the encrypted file
c. encrypts the data from the input file by performing xor of the key with every byte from the input file
3. has a function for decryption
a. reads the key from the encrypted file
b. decrypts the data from the input file by performing xor of the key wit every byte from the file
4. performs the encryption or decryption based on the user's choice.
Why do you ask for both the infile and the outfile? You should only ask the question appropriate to what the user has selected (and perhaps perform some error checking). A switch statement might suit you best:
I am uncertain of what I should ask for the case. I used .get to read the input and output file but it is not working correctly. This program is giving me a headacher!
What is this program supposed to output? you have not coded encrypt and decrypt yet
Simplest encrypt algorithm would be xor each of the byte of the input with a magic number, where exactly are you stuck ?
Char arrays would be kind of silly when you could simply use a C++ string to hold the data. You then directly reference each character using the string's [] overloaded operators, and simply perform the XOR with the key. To decrypt it, simply use the XOR with the key again, and the character will be readable.
Not to say that it's a very secure method of encryption, but it will suffice for a homework assignment like this one...
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.