chunk

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeChunkHash

func ComputeChunkHash(data []byte) string

ComputeChunkHash computes SHA256 hash of chunk data

func ReassembleChunks

func ReassembleChunks(chunks [][]byte) []byte

ReassembleChunks combines chunks back into a single file

func ShouldChunk

func ShouldChunk(fileSize int64, thresholdBytes int64) bool

ShouldChunk returns true if a file should be chunked based on threshold

func SplitFile

func SplitFile(data []byte, chunkSizeBytes int) [][]byte

SplitFile splits data into fixed-size chunks

func VerifyChunkIntegrity

func VerifyChunkIntegrity(chunk []byte, meta ChunkMetadata) error

VerifyChunkIntegrity verifies a single chunk against its metadata

func VerifyChunks

func VerifyChunks(chunks [][]byte, expectedFileHash string) error

VerifyChunks verifies that chunks reassemble to the expected file hash

Types

type ChunkDiff

type ChunkDiff struct {
	Index int    // Chunk index
	Data  []byte // Diff data for this chunk
	Hash  string // Hash of the diff data
}

ChunkDiff represents a diff for a single chunk

type ChunkMetadata

type ChunkMetadata struct {
	FileHash    string // SHA256 hash of the entire file
	ChunkIndex  int    // Index of this chunk (0-based)
	TotalChunks int    // Total number of chunks in the file
	ChunkSize   int    // Size of this chunk in bytes
	ChunkHash   string // SHA256 hash of this chunk's data
}

ChunkMetadata contains metadata about a file chunk

func CreateMetadata

func CreateMetadata(fileData []byte, chunks [][]byte) []ChunkMetadata

CreateMetadata creates metadata for chunks

Jump to

Keyboard shortcuts

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