hashio

package
v0.0.0-...-23e6066 Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package hashio provides hash-verified I/O streams.

The I/O stream format is defined as follows.

/-----------------------------------------\ | payload | +-----------------------------------------+ | hash | +-----------------------------------------+ | payload | +-----------------------------------------+ | hash | +-----------------------------------------+ | ...... | \-----------------------------------------/

Payload bytes written to / read from the stream are automatically split into segments, each followed by a hash. All data read out must have already passed hash verification. Hence the client code can safely do any kind of (stream) processing of these data.

Index

Constants

View Source
const SegmentSize = 8 * 1024

SegmentSize is the unit we split payload data and insert hash at.

Variables

View Source
var ErrHashMismatch = errors.New("hash mismatch")

ErrHashMismatch is returned if the ErrHashMismatch does not match.

Functions

func NewReader

func NewReader(r io.Reader, h hash.Hash) io.Reader

NewReader creates a hash-verified IO stream reader.

func NewWriter

func NewWriter(w io.Writer, h hash.Hash) io.WriteCloser

NewWriter creates a hash-verified IO stream writer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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