Thread: How to Checksum Binary File using XOR

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    1

    How to Checksum Binary File using XOR

    Hi,

    I need to determine the Checksum using the logical "XOR" of all the 32-bit words from a binary/image file.

    I am fairly new to low level programming, please correct me if I am wrong:

    Code:
        fstream infile("file.bin", ios::in);
        if (infile.fail())
        {
            return 0;
        }
    
        int checksum = 0;
        int currentInt = 0;
        while(infile >> currentInt)
        {
            checksum = checksum ^ currentInt;
        }
    Thank you

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Maybe you want LRC

    See also this post

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading and writing to a binary file
    By greg677 in forum C Programming
    Replies: 2
    Last Post: 05-24-2010, 08:09 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. copying binary file
    By samc2004 in forum C Programming
    Replies: 5
    Last Post: 12-09-2003, 01:34 PM