Transfer of byte-array between two hosts

  • Thread starter Thread starter Jesper Stocholm
  • Start date Start date
J

Jesper Stocholm

I have a little problem that I am not sure how to solve.

I need to transfer a byte-array between a server and a client using
TCP/IP. The challenge is that it needs to be encapsulated in XML, but
XmlSerialization is not an option, since it is an extension of an
existing design.

The Xml could look like

<data>
<User>
<UserName>stocholm</UserName>
<Age>30</Age>
<PthPreImage>[... byte array goes here ...]</PthPreImage>
</User>
</data>

I need to be able to "restore" the value in Xml to the original byte-
array on the server, since it needs to be applied to SHA1 to verify the
integrity of a "hash-chain" of values.

How the heck do I do this? I am completely blanc with respect to a
solution, so I will be very grateful for a bit of help.

Thanks, :o)
 
Jesper Stocholm said:
I need to be able to "restore" the value in Xml to the original byte-
array on the server, since it needs to be applied to SHA1 to verify the
integrity of a "hash-chain" of values.

How the heck do I do this? I am completely blanc with respect to a
solution, so I will be very grateful for a bit of help.

I'd suggest using base 64, as it's reasonably compact and there already
conversion routines in the framework:

Convert.ToBase64String
Convert.FromBase64String
 
Jon Skeet [C# MVP] wrote :
I'd suggest using base 64, as it's reasonably compact and there already
conversion routines in the framework:

Convert.ToBase64String
Convert.FromBase64String

Aaah, yes - of course. Can't believe I missed that.

:o)
 
Back
Top