How to verify data integrity between client-server connection?
-
10-06-2021 - |
Question
I recently developed an online multiplayer game and it's working fine. There's a central server handling TCP connections with clients, and they both receive and send data.
Is there a way to verify that the data sent hasn't been modified before the receiver reads it?
Does a TCP connection handle it in some way? If not what is the best way (not asking for code) to implement it?
By now I came up with those ideas:
- Modify the data sent adding some sort of verify-value, such the packet length.
- When a packet is received, ask the server to send it again and verify if they are equal.
I searched for a common used solution but couldn't find much.
Encryption should be my last option.
Edit
For a simple way to achieve this:
Solution
Agreed with Bart, you may want to look at using a Hash method for data verification.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow