Class FitsCheckSum

java.lang.Object
nom.tam.fits.utilities.FitsCheckSum

public final class FitsCheckSum extends Object
  • Method Details

    • checksum

      public static long checksum(byte[] data)
      Calculate the Seaman-Pence 32-bit 1's complement checksum over the byte stream. The option to start from an intermediate checksum accumulated over another previous byte stream is not implemented. The implementation accumulates in two 64-bit integer values the two low-order and the two high-order bytes of adjacent 4-byte groups. A carry-over of bits is never done within the main loop (only once at the end at reduction to a 32-bit positive integer) since an overflow of a 64-bit value (signed, with maximum at 2^63-1) by summation of 16-bit values could only occur after adding approximately 140G short values (=2^47) (280GBytes) or more. We assume for now that this routine here is never called to swallow FITS files of that size or larger. by R J Mathar Checksum.CHECKSUM
      Parameters:
      data - the byte sequence
      Returns:
      the 32bit checksum in the range from 0 to 2^32-1
      Since:
      2005-10-05
    • checksumEnc

      public static String checksumEnc(long c, boolean compl)
      Encode a 32bit integer according to the Seaman-Pence proposal.
      Parameters:
      c - the checksum previously calculated
      compl - complement the value
      Returns:
      the encoded string of 16 bytes.
      See Also:
    • setChecksum

      public static void setChecksum(BasicHDU<?> hdu) throws FitsException
      Add or update the CHECKSUM keyword. by R J Mathar
      Parameters:
      hdu - the HDU to be updated.
      Throws:
      FitsException - if the operation failed
      Since:
      2005-10-05