Skip to content

Implement checksum algorithm. A checksum is used to detect erros during data transmission in network.

Notifications You must be signed in to change notification settings

rohitnitk/socket-programming-checksum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Socket programming with Checksum

Improtant piece of code that calculates checksum is:

public byte calculateCheckSum(byte[] dataInBytes) {
        int sum = 0;
        for (int i = 0; i < dataInBytes.length; i++) {
            sum += (dataInBytes[i]);
            int carry = (sum >> 7) & 1;
            if (carry == 1) {
                sum = sum & 127;
                sum += 1;
            }
        }

        byte checksum = (byte) (sum ^ 127);
        return checksum;
    }
    

Othe code is used from GFG

About

Implement checksum algorithm. A checksum is used to detect erros during data transmission in network.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages