Encryptor

Reply

Join Date: Feb 2007
Posts: 3
Reputation: hellokitkat is an unknown quantity at this point 
Solved Threads: 0
hellokitkat hellokitkat is offline Offline
Newbie Poster

Encryptor

 
0
  #1
Feb 22nd, 2007
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.

so far I have ( Not quite sure what to do next):

#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
#include<fstream>
usingnamespace std;
void encrypt();
void decrypt();
char option;
// char inFile;
char outFile;
int decryptencrypt;
void main()
{
srand((unsigned)time(NULL));
encrypt();
decrypt();
cout << "Enter 1 to decrypt" << endl;
cout << "Enter 2 to encrypt" << endl;
cin >> decryptencrypt;
cout << "Enter the input filename" << endl;
cin >> option;
// cin.get(inFile);
string inFile;
getline(cin, inFile);
cout << "Enter the output filename" << endl;
cin >> outFile;
}
void encrypt(){
char t
}
void decrypt(){
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Encryptor

 
0
  #2
Feb 22nd, 2007
You ain't done much.

Specifically which part are you struggling with?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,050
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 331
Moderator
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Encryptor

 
0
  #3
Feb 22nd, 2007
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:
  1. switch (decryptencrypt) {
  2. case 1:
  3. // ask for infile, call decrypt(), blah blah
  4. break;
  5. case 2:
  6. // ask for outfile etc
  7. break;
  8.  
  9. default:
  10. // invalid choice
  11. }
And don't forget to allow a string parameter for encrypt()/decrypt(), or else it won't know what file to open!

But agreed with iamthwee, you haven't written much. What don't you know about writing an encrpytion program?
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 3
Reputation: hellokitkat is an unknown quantity at this point 
Solved Threads: 0
hellokitkat hellokitkat is offline Offline
Newbie Poster

Re: Encryptor

 
0
  #4
Feb 23rd, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,782
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 113
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso

Re: Encryptor

 
0
  #5
Feb 23rd, 2007
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 ?
Last edited by ithelp; Feb 23rd, 2007 at 9:57 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 103
Reputation: Tauren is an unknown quantity at this point 
Solved Threads: 0
Tauren Tauren is offline Offline
Junior Poster

Re: Encryptor

 
0
  #6
Feb 26th, 2007
You might wanna use Arrays.
A winner is a loser that got up and gave it one more shot!

A programmer is a failer that edited the code and got it work!
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,050
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 331
Moderator
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Encryptor

 
0
  #7
Feb 26th, 2007
Originally Posted by Tauren View Post
You might wanna use Arrays.
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...
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC