Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 930401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:19:40+00:00 2026-05-15T20:19:40+00:00

I need a small program that can calculate the checksum from a user input.

  • 0

I need a small program that can calculate the checksum from a user input.

Unfortunately, all I know about the checksum is that it’s xor all data in packet.

I have tried to search the net for an example without any luck.

I know if I have a string: 41,4D,02,41,21,04,02,02,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

This should result in a checksum of 6A.

Hopefully someone could help me. If someone has an example writen in Python 3, could also work for me

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:19:41+00:00Added an answer on May 15, 2026 at 8:19 pm

    If I understand “xor all data in packet” correctly, then you should do something like this:

    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    int main() 
    {
      unsigned int data;
      vector< unsigned int > alldata;
    
      cout << "Enter a byte (in hex format, ie: 3A ) anything else print the checksum of previous input: ";
    
      while ( true )
      {
        cin >> hex >> data;
    
        if ( cin.fail() || cin.bad() )
            break;
    
        alldata.push_back( data );
        cout << "Enter a byte: ";
    
      }
    
      unsigned int crc = 0;
    
      for ( int i = 0; i < alldata.size(); i++ )
          crc ^= alldata[ i ];
    
      cout << endl << "The checksum is: " << hex << uppercase << crc << endl;
    
      system( "pause" );
    
      return 0;
    }
    

    The idea is to establish a variable initialized to 0 and then xor all elements of the packet with it while storing the result of the operation in the same variable on each step.

    EDIT: edited the answer to provide complete working example (far from perfect, but works).
    Usage: enter bytes as required, once you are finished with input, enter anything invalid, for example q (cannot be a hexadecimal number). You will get the checksum printed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a small program that can detect that it has been
I am writing a small program that sends and receive multicast packets.I need to
I am writing a small program that gets activated when sms is received.We need
I'm about to implement a small program where i need the elapsed seconds since
We need to make some small program for school that rolls 5 dices and
For Example: I need to develop a Small Inventory program for nearby Super Market
I need to read small sequences of data from a 3.7 GB file. The
I am writing a small test program that gives the following xml file as
I am running a small registration program (provided by the development tool company) that
I am adding a small feature in a program that uses access 97 db.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.