Thanks dhayden and jlb for your replies.
I'm starting think that I need to take a different approach.
Essentially the file line numbering is there so that the program knows where to look for specific data and if necessary, write over the existing data. Up until I've got to the stage where I would like to encrypt / decrypt this data It has been working.
Forgive me if I'm wrong here as I've only been programming (regularly) for 6 - 9 months...
I get that a binary file has just the one line. Thus it would convert a '\n' - like character into a series of numbers based on the key that is used in the XOR encryption.
I'm thinking that two differnt appraoches to how my data is written may help. So far I have data like this in a txt file:
1 2 3 4
|
001: User data line 1
002: User data line 2
003: User data line 3
.....and so on.....
|
Option 1: Use something other than XOR encryption, or
Option 2: write my data so that is has a character that marks the end of that piece of data. For example, my data file would look like (before encryption):
001: User data line 1@002: User data line 2@003: User data line 3@..... and so on....
Where the '@' signifies the end of the piece of data.
This means that there are no \n characters which may help. The only thing I can see here reflects on what you said, jlb regarding reading / writing exactly the same number of characters... Writing the code to say repalce the piece of data that lies inbetween other data would be difficult.
How do these ideas sound?
Cheers,