|Subject:||ConnectionIntercept stream question|
|Posted by:||Jack Mays (jackmays…@SPAMsupplant.net)|
|Date:||Sun, 14 Dec 2003|
I'm workin with the IdTCPServer and intercepts so that i can decrypt/encrypt
data before the data hit the command handler. What i was told is that i
have to re-write the AStream at the end of the intercept so that it is
passed to the command handler, or out the socket.
The problem is i can't seem to erase what's in AStream so that i can rewite
it with the decrypted data.. below is an example of some things i've tried..
If anyone could help me figure this out it would be great.. you'll see by
the comments, i got desperate to find a solution.. I"m not that strong with
streams either, so this may be something completely simple that i'm just
Client : TClientInfo;
encString, decString: String;
text: string; // temp use for debugging.
// Get the client data for this client intercept
Client := Pointer(Self.Data);
Data := TStringStream.Create('');
Data2 := TStringStream.Create('');
encString := Trim(Data.DataString); // must trim
decString := DecryptData(encString, Client.SymKey, Client.SymKeyType,
Client.SymKeyBitSize, Client.RSAProcessed, Client.FirstReceived);
// Resetting the position on both streams, when doing the writestring, it
// will overwrite the currect contents, if you dont reset the position it
// will concantionate them together.
Data.Position := 0;
//Data2.Position := 0;
AStream.Position := 0;
// Putting the decrypted data into the temp stringstream.
Text := Data.DataString;
// Write the decrypted stringstream to the intercept so it will be
// passed to the command handlers.
//AStream := Data;
// AStream.Size := Length(Text);
// Data2.Write(Text, Length(Text));
AStream := (Data as TStream);
//AStream.CopyFrom(Data, 0); // 0 means start at pos 0 and read all
Text := Data2.DataString;