The CHECKSUM and DATASUM keywords are used to embed a 32-bit 1's complement checksum into each HDU of the FITS file which can be used to verify the integrity of the file. The CHECKSUM keyword gives an ASCII encoded representation of the complement of the checksum for the entire HDU. A valid CHECKSUM keyword value causes the checksum for the whole HDU to have a value of zero. The DATASUM keyword gives the 32-bit unsigned integer value for the checksum of the data unit alone, stored as an ASCII string. Further details of this checksum algorithm have been published by Rob Seaman in the Astronomical Society of the Pacific Conference Series, Volume 77, "Astronomical Data Analysis Software and Systems IV" and in a revised draft dated June 1995.
This task may be used to either verify the checksums in a file or to update the checksum keyword values if they do not exist or are out of date. If the 'update' parameter has the default value of 'no' then the input file is not modified and the checksums are merely verified; a warning message is issued if the checksum values are not correct, thus indicating that the file has been modified or corrupted since the checksum keywords were originally written.
If an existing FITS file does not contain the checksum keywords or if the keyword values are out of date, then this task may be used to compute the new checksum keyword values by specifying 'update = yes'. If the FITS file already has the correct DATASUM keyword value in each HDU and only the header(s) have been modified then the CHECKSUM keywords can be quickly updated by specifying 'datasum = no'. Specifying 'yes' for this parameter will force the DATASUM keyword to be recomputed (which may take some time for large files) and updated if necessary before recomputing the CHECKSUM keyword value in each HDU.
Note that the ftverify task also checks the values of the checksum keywords if they are present.
1. Verify the checksum values, without updating the input file.
ftchecksum test.fits
2. Verify the checksum keywords in the input file and update the values if the keywords don't exist or have invalid values. Chatter = 0 turns off all the diagnostic output.
ftchecksum test.fits update=yes chatter=0
3. Update the checksum keywords in a list of files contained in the filelist.txt text file.
ftchecksum @filelist.txt update=yes
fv, the interactive FITS file editor, can also be used to create and verify the checksum keywords FITS HDUs.