简体   繁体   中英

Java/C# communication over TCP - Signed/unsigned bytes pro

I have an application in Java which sends messages over TCP. And another application which is C# which listens to this message and responds. The problem is, JAVA bytes are signed and it encrypts the message and sends it- Has many negative numbers in the encrypted message. Now at C# side,i need to decrypt the message- Since C# bytes are unsigned, im not sure what happens to the negative numbers being sent. Will my decryption fail?

Bytes can be viewed either as numbers (signed or unsigned) or as "arrays" of 8 bits.

  • When you encrypt some data and send it as a sequence of bytes, what you are effectively sending is a sequence of arrays of bits. And that is what is being received.

  • When you have an array of 8 bits on your hand, you can view it as either a signed or unsigned number. But the act of viewing it as one or the other does not transform the bit pattern.

Therefore, if you are sending encrypted data as a sequence of bytes it does not matter if the sender and receiver's idea of a bytes ... as numbers ... is the same.

Will my decryption fail?

No.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM