checksum

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package checksum implements the S3 x-amz-checksum-* algorithms and the headers that carry them. It depends only on the standard library so it can be reused by any service that speaks the S3 checksum protocol.

Index

Constants

View Source
const HeaderPrefix = "x-amz-checksum-"

HeaderPrefix is the prefix an algorithm's checksum header carries ("x-amz-checksum-" + the lower-case algorithm name). It is exported because the name is built in one place and parsed in another: a chunked body's trailer names the header, and the caller verifying that trailer must build the same name this package's TrailerAlgorithm cut off it.

Variables

This section is empty.

Functions

func Base64

func Base64(h hash.Hash) string

func NewHash

func NewHash(alg string) hash.Hash

NewHash returns a hasher for the algorithm; the base64 of its Sum(nil) is the x-amz-checksum-* value. Returns nil for unsupported algorithms.

func SetHeaders

func SetHeaders(h http.Header, cs Values, checksumType string)

SetHeaders sets x-amz-checksum-* response headers.

func TrailerAlgorithm

func TrailerAlgorithm(h http.Header) string

TrailerAlgorithm returns the checksum algorithm declared in the x-amz-trailer header ("x-amz-trailer: x-amz-checksum-crc32" -> "crc32"), or "" if the request declares no checksum trailer.

Types

type Values

type Values struct {
	CRC32     *string
	CRC32C    *string
	CRC64NVME *string
	SHA1      *string
	SHA256    *string
}

Values carries the x-amz-checksum-* values of a request or response.

func FromHeaders

func FromHeaders(h http.Header) Values

func (Values) Algorithm added in v0.0.5

func (v Values) Algorithm() string

Algorithm returns the upper-case name of the algorithm a value is set for ("" when none) — the form x-amz-sdk-checksum-algorithm and the SDK's ChecksumAlgorithm parameter use. A request carries at most one checksum.

Jump to

Keyboard shortcuts

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