Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to verify data integrity between client-server connection?

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:

  1. MD5
    • Wikipedia
    • Example
  2. SHA1
    • Wikipedia
    • Example
  3. SSL
    • Wikipedia
    • Example
like image 769
mastaH Avatar asked May 24 '12 23:05

mastaH


People also ask

How is data integrity achieved?

Achieved through a variety of data protection methods, including backup and replication, database integrity constraints, validation processes, and other systems and protocols, data integrity is critical yet manageable for organizations today.

Which of the following principles are key elements of data integrity?

According to the ALCOA principle, the data should have the following five qualities to maintain data integrity: Attributable, Legible, Contemporaneous, Original and Accurate.


1 Answers

Agreed with Bart, you may want to look at using a Hash method for data verification.

like image 95
BenSchro10 Avatar answered Sep 24 '22 00:09

BenSchro10