decryption filter

Hello, How can decrypt the file that the program below encrypt?
Please I need with this.

// This program encrypts a file


using namespace std;

int main()
const int ENCRYPT=10; // amount to add to a chor
const int SIZE= 255; // array size
char inFileName[SIZE];
char data; // to hold a char from a file

ifstream inputFile; // input file stream object
ofstream outputFile; // output file stream object

// Get the name of the input file.
cout<< "Enter the name of the file to encrypt.\n";
cin.getline(inFileName, SIZE);

// Open the files. (inFileName);"encrypted.txt");

// Readnthe first character from the input file.

//While data is available from the input file
// encrypt it and write to the output file.

while( !inputFile.eof())
// Encrypt the character.

data += ENCRYPT;

// Write the encrypted data.

//Read the next character.
// Close the files.


// We're done

cout<< "The file " << inFileName
<< " was encrypted and saved to encrypted.txt."
<< endl;
return 0;
To decrypt something that is encrypted, you are essentially reversing the process. You need the encryption key, which you have already (ENCRYPT), so you just need a function that takes your encrypted file and reverses the encryption.
agree with randisking, however in some cases there are no way to reverse the encryption but in your code it so easy

input: 123

1  2  3   text
;  <  =   after encrypting

how this happens?

1  2  3   text
49 50 51  decimal
59 60 61 << ENCRYPT adds 10 to each...
;  <  =   text 

so as randisking said

;  <  =   text
59 60 61
49 50 51  << after subtracting 10
1  2  3   text
Last edited on
Topic archived. No new replies allowed.