checksum

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMismatch = errors.New("checksum mismatch error")

ErrMismatch indicates a checksum verification failure due to a derived checksum not being equal to expected checksum

Functions

func Verify

func Verify(
	payload codec.ThriftObject,
	checksum Checksum,
) error

Verify verifies that the checksum generated from the given thrift object matches the specified expected checksum Return ErrMismatch when checksums mismatch

Types

type Checksum

type Checksum struct {
	// Version represents version of the payload from
	Version int
	// which this checksum was derived
	Flavor Flavor
	// Value is the checksum value
	Value []byte
}

Checksum represents a checksum value along with associated metadata

func GenerateCRC32

func GenerateCRC32(
	payload codec.ThriftObject,
	payloadVersion int,
) (Checksum, error)

GenerateCRC32 generates an IEEE crc32 checksum on the serilized byte array of the given thrift object. The serialization proto used will be of type thriftRW

type Flavor

type Flavor int

Flavor is an enum type that represents the type of checksum

const (
	// FlavorUnknown represents an unknown/uninitialized checksum flavor
	FlavorUnknown Flavor = iota
	// FlavorIEEECRC32OverThriftBinary represents crc32 checksum generated over thriftRW serialized payload
	FlavorIEEECRC32OverThriftBinary
)

func (Flavor) IsValid

func (f Flavor) IsValid() bool

IsValid returns true if the checksum flavor is valid

Jump to

Keyboard shortcuts

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