Hi, I have been making a program that encrypts files. It works, but it compresses them. It only does it a little bit, but it does. It's weird. Why is it doing this?
I have attached a zipped folder with the code, binary, an encrypted file, and the original file. The key to decrypt the file is "hello" without quotes. Once you decrypt the included file, you'll see that they are now the same size.
Don't continue. You try to deallocate (free) stack (automatic) array. Of course, now program stack is corrupted, program behaviour is undefined and so on...
Apropos, see quote from C++ Standard:
126.96.36.199.2 Global names
Certain sets of names and function signatures are always reserved to the implementation:
— Each name that contains a double underscore _ _ or begins with an underscore followed by an uppercase letter (2.11) is reserved to the implementation for any use.
— Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
So it's not recommended to assign __TEMP__ to your local variables: it's not a good practice.
On Windows, the newline character represents the ASCII sequence CR LF.
When your program reads it, it gets '\n'. The newline is encrypted thus and so the output file is shorter than the input file, because the encrypted data doesn't have as many '\n's (if any) as the source.
You'll also notice that when it says File Length: that it gives the shorter size.
When decrypting, you get back that '\n', which is written to file as CR LF, thus increasing the output file size (back to the original size).
<conio.h> is evil.