I have java
code as
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(tokenBytes);
baos.write(signedData);
byte[] finalout = baos.toByteArray();
where tokenBytes and signedData are byte arrays.In c#
I have written as
using (MemoryStream stream = new MemoryStream())
{
using (BinaryWriter writer = new BinaryWriter(stream))
{
writer.Write(tokenBytes);
writer.Write(signature);
}
finalBytesToSend = stream.ToArray();
}
where tokenBytes , signature and finaleBytesToSend are byte arrays.
Is it correct? OR is there any other way to do it?
Presumably I assume you are writing a Java-C# serialization scheme. I think there are 3 things you might want to be careful:
In my opinion if you are transferring data between Java and C#, you'd better use simply ByteBuffer in Java side and MemoryStream/BinaryReader/BinaryWrite in C# side. Setting UTF-16 Big Endian correctly in C# side, and write your own de-serializer for stuff like int/long/double primitives. That makes it work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With