AWS SDK for Go (PILOT)
API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see https://docs.aws.amazon.com/sdk-for-go/api/.

We welcome your feedback on this new version of the documentation. Send your comments to aws-sdkdocs-feedback@amazon.com.

ComputeTreeHash

import "github.com/aws/aws-sdk-go/service/glacier"

func ComputeTreeHash(hashes [][]byte) []byte

ComputeTreeHash builds a tree hash root node given a slice of hashes. Glacier tree hash to be derived from SHA256 hashes of 1MB chucks of the data.

See https://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html for more information.

hashes

Type: [][]byte

[]byte

Type: []byte

Example

ComputeTreeHash

{ r := testCreateReader() const chunkSize = 1024 * 1024 // 1MB buf := make([]byte, chunkSize) hashes := [][]byte{} for { n, err := io.ReadAtLeast(r, buf, chunkSize) if n == 0 { break } tmpHash := sha256.Sum256(buf[:n]) hashes = append(hashes, tmpHash[:]) if err != nil { break } } treeHash := glacier.ComputeTreeHash(hashes) fmt.Printf("TreeHash: %x\n", treeHash) }

On this page: