Documentation
¶
Overview ¶
Package checksum provides a wrapper to compute a checksum on a writable file while it is being written to, and record the final checksum when the file is closed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { // Performs the checksuming, provides implementations for Write and // WriteString *crypto.Sha256SumWriter // contains filtered or unexported fields }
File is a writable file that will compute its checksum while it is written to. When closed, it will write its checksum to the provided io.Writer. The checksum is written in a format so that it can be verified by sha256sum.
func NewFile ¶
NewFile wraps the provided writerFile in a checksumed File. When the file is closed, its checksum will be written to cs.
func (*File) Close ¶
Close closes the Sha256SumWriter, computes the checksum and writes it to f.checksumWriter
type Sha256Sums ¶
Sha256Sums is a map of file names with their corresponding SHA256SUM.
func LoadSha256Sums ¶
func LoadSha256Sums(r io.Reader) (Sha256Sums, error)
LoadSha256Sums reads from an io.Reader to populate the Sha256Sums map The reader is expected to return the sums in a format that is compatible with sha256sum, that is each line should contain the hex encoded sum followed by a separator and then the file name. The separator should either be two spaces (" ") or a space an asterisks (" *"). The former indicates a text file and the later a binary file. However, there is no difference between these for GNU systems. Therefore this also makes no distinction between the separators and checks for either.