checksums

package
v0.3.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checksums

type Checksums struct {
	// MD5 is the MD5 hash value of the associated blob object.
	MD5 []byte `datastore:",noindex"`
	// CRC32C is the CRC32C checksum of the associated blob object.
	// CRC32C uses the Castagnoli polynomial.
	// This needs to be int32 because Datastore doesn't support unsigned integers...
	// Use SetCRC32C() and GetCRC32C() for easier access.
	CRC32C int32 `datastore:",noindex"`
	// HasCRC32C indicates if there is a valid CRC32C value.
	HasCRC32C bool `datastore:",noindex"`
}

Checksums is a struct for blob checksums.

func (*Checksums) GetCRC32C

func (c *Checksums) GetCRC32C() uint32

GetCRC32C returns CRC32C.

func (*Checksums) ResetCRC32C

func (c *Checksums) ResetCRC32C()

ResetCRC32C clears the CRC32C value and sets HasCRC32C to false.

func (*Checksums) SetCRC32C

func (c *Checksums) SetCRC32C(v uint32)

SetCRC32C sets v to CRC32C and sets HasCRC32C to true.

func (*Checksums) ValidateIfPresent

func (c *Checksums) ValidateIfPresent(p ChecksumsProto) error

ValidateIfPresent checks if the checksum values match with p. Returns a DataLoss error if they don't.

type ChecksumsProto

type ChecksumsProto interface {
	GetHasCrc32C() bool
	GetCrc32C() uint32
	GetMd5() []byte
}

ChecksumsProto represents an proto message that has checksum values.

type Digest

type Digest struct {
	// contains filtered or unexported fields
}

Digest calculates MD5 and CRC32C values as you call Write and returns the values as a Checksums variable.

func NewDigest

func NewDigest() *Digest

NewDigest creates a new instance of Digest.

func (*Digest) Checksums

func (d *Digest) Checksums() Checksums

Checksums returns a new Checksums variable with the calculated hash values.

func (*Digest) Reset

func (d *Digest) Reset()

Reset resets the hash states.

func (*Digest) Write

func (d *Digest) Write(p []byte) (int, error)

Write adds more data to the running hashes. It never returns an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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