checksum

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package checksum implements the FITS checksum algorithm defined in Appendix J of the FITS Standard v4.0.

The FITS checksum is a 32-bit 1's-complement sum computed over the big-endian uint16 view of an HDU's 2880-byte-aligned bytes. Overflow bits are folded back into the low 16 bits so that every bit position is sampled evenly. The final 32-bit value is ASCII-encoded via Rob Seaman's encoding so that the CHECKSUM keyword value is printable and round-trippable.

Port of cfitsio checksum.c (ffcsum / ffesum / ffdsum). Algorithm verbatim, idioms Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compute

func Compute(data []byte) uint32

Compute returns the 32-bit 1's-complement checksum of the supplied bytes. The length must be a multiple of 4 (i.e. the caller has already padded the input to the block boundary as FITS requires).

func Decode

func Decode(ascii [16]byte, complement bool) uint32

Decode is the inverse of Encode. It returns the 32-bit checksum sum that produced the given 16-character ASCII encoding.

func Encode

func Encode(sum uint32, complement bool) [16]byte

Encode converts a 32-bit 1's-complement checksum into its 16-character ASCII representation per Appendix J.

If complement is true the function encodes the bit-wise complement of sum, which is the form written to the CHECKSUM keyword.

func Update

func Update(sum uint32, b []byte) uint32

Update folds the 2880-byte block b into the running 32-bit 1's-complement checksum sum and returns the new value. It is the caller's responsibility to ensure b is exactly 2880 bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL