Hi all,
OK I give up. I have spent way too much time trying to figure this one out...
I created a file download service running between two B4P apps, one pda/client the other a xp/server. I have no problem with the file transers working smoothly (based on code examples using the BinaryFile lib).
Now I'd like to encrypt the data for protection. I have been able to figure out how to encrypt handshaking data packets between client and server using the HTTP lib GetStream, but for the life of me I can't get the encryption structure figured out on a binary file transfer using WriteBytes2.
What I have kinda figured out:
1. Reading a file:
count = fileStream.ReadBytes(buffer(),8192) ' to read the 1st 8K packet
2. Encrypting the buffer:
count2() = Crypto.Encrypt(ED, buffer()) ' to encrypt the count packet above
I read 8192 instead of 8200 because (I think) crypto is adding 8 bytes to the buffer.
3. Sending the encrypted buffer:
newcount = ArrayLen(count2)
Do While newcount > 0
fileStream1.WriteBytes2(me(),0,newcount)
size = size - count << where size = fileStream.Length ... << another problem is the ending 8K packet will be of unknown size.
Even trying to decode just a single 8K packet (without worrying about subsequent packets) I keep getting "Bad Data" errors from Decrypt. Obviously my strutures aren't matching between the encrypted buffer and the decrypted, but I've been wracking my head and it really hurts now! :sign0148::sign0148:
I'd be forever greatfull on any guidance!!
OK I give up. I have spent way too much time trying to figure this one out...
I created a file download service running between two B4P apps, one pda/client the other a xp/server. I have no problem with the file transers working smoothly (based on code examples using the BinaryFile lib).
Now I'd like to encrypt the data for protection. I have been able to figure out how to encrypt handshaking data packets between client and server using the HTTP lib GetStream, but for the life of me I can't get the encryption structure figured out on a binary file transfer using WriteBytes2.
What I have kinda figured out:
1. Reading a file:
count = fileStream.ReadBytes(buffer(),8192) ' to read the 1st 8K packet
2. Encrypting the buffer:
count2() = Crypto.Encrypt(ED, buffer()) ' to encrypt the count packet above
I read 8192 instead of 8200 because (I think) crypto is adding 8 bytes to the buffer.
3. Sending the encrypted buffer:
newcount = ArrayLen(count2)
Do While newcount > 0
fileStream1.WriteBytes2(me(),0,newcount)
size = size - count << where size = fileStream.Length ... << another problem is the ending 8K packet will be of unknown size.
Even trying to decode just a single 8K packet (without worrying about subsequent packets) I keep getting "Bad Data" errors from Decrypt. Obviously my strutures aren't matching between the encrypted buffer and the decrypted, but I've been wracking my head and it really hurts now! :sign0148::sign0148:
I'd be forever greatfull on any guidance!!