read file corrupting??


2005-02-10 11:04:57 PM
cppbuilder23
Hi, I'm trying to write a simple command line rc4 encryption program.
Basically you type in the key, an input file and an output file.
The program should read the input file and encrypt the string using
the rc4 encryption algorithm then the program writes the string to the
output file.
If you run rc4 on a string twice (with the same key) you should end up
with what you started with (unencrypted)
However when I run my program twice it doesn't end up with what it
started with so I assumed I must have made a mistake in the rc4 code.
But if you get the program to run the rc4 algorithm twice in one
execution (ie it doesn't save to the file then read it again it just
does the algorithm twice) then you *DO* get what you started with (it
works).
I guess therefore it must be something to do with saving and loading
files in bcc32/dos/ascii/ansi or whatever the stdio uses.
Anyone got any ideas what I'm doing wrong?