FITS Checksum Proposal R.L. Seaman and W.D. Pence 24 August 1995 ABSTRACT This paper describes a simple means for embedding a checksum within a FITS header, providing a mechanism for later verifying the integrity of the FITS file. The method uses ASCII coded 32 bit 1's complement arithmetic to force the checksum of each FITS HDU to zero. This technique requires no extension of the FITS standard to be used by any given project, in fact the technique may be used to zero the checksum of any ASCII file. The purpose of this proposal is simply to reserve keywords that will allow projects and software packages to seamlessly verify and update each other's data. -------- A copy of the proposal is available via anonymous ftp from iraf.noao.edu in the /misc/checksum directory, where you will find the following files: README this file checksum.ps FITS Checksum Proposal, Seaman & Pence stb602173.fits FITS file w/ CHECKSUM and DATASUM keywords sum32.tar simple C program to calculate the 32 bit 1's complement checksum and to ASCII encode the checksum (w/ SunOS binary) FITS.sum.example pseudo FITS header with CHECKSUM keyword FITS.sum.zeroed same header with the checksum zeroed RFC directory containing pertinent Internet "Request For Comment" documents old_drafts previous drafts of the proposal -------- The two files, FITS.sum.example and FITS.sum.zeroed, are an example of how the technique works. Before accumulating the checksum for a FITS file, set the value of the CHECKSUM keyword to all 0's: SIMPLE = T / BITPIX = 8 / NAXIS = 0 / to align the next keyword CHECKSUM= '0000000000000000' / ASCII 1's complement checksum DATASUM = ' 0' / checksum of data records CHECKVER= 'COMPLEMENT' / checksum version ID END (The comment for the NAXIS keyword shifts the alignment of the CHECKSUM keyword to impersonate real FITS - these are not 80 character cardimages.) For this example, calculate the checksum using the sum32 program: % sum32 -p FITS.sum.example checksum16: 25128 = 3JAH3HAH complement: 40407 = eXhWeWeW checksum32: 4109921583 = 5mnLAmnK8mnKAmnK complement: 0185045712 = d54Vd21Td21Td21T file size: 309 bytes (The -p tells the program to permute the ASCII encoding for the odd byte alignment required by placement of the FITS keyword value.) Edit the header to replace the 0's with the complement of the checksum (32 bit version): SIMPLE = T / BITPIX = 8 / NAXIS = 0 / to align the next keyword CHECKSUM= 'd54Vd21Td21Td21T' / ASCII 1's complement checksum DATASUM = ' 0' / checksum of data records CHECKVER= 'COMPLEMENT' / checksum version ID END with the result that the checksum of the FITS header (or file, or extension) is set to zero: % sum32 FITS.sum.zeroed checksum16: 65535 = rroooooo complement: 00000 = 00000000 checksum32: 4294967295 = rrrroooooooooooo complement: 0000000000 = 0000000000000000 file size: 309 bytes To later verify the file, accumulate the checksum and see if the checksum is still zero. Rob Seaman seaman@noao.edu Bill Pence pence@tetra.gsfc.nasa.gov