hash

package
v0.0.0-...-0fedc61 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2015 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashingWriter

type HashingWriter struct {
	// contains filtered or unexported fields
}

HashingWriter wraps an io.Writer, providing the checksum of all data written to it. A HashingWriter may be used in place of the writer it wraps.

func NewHashingWriter

func NewHashingWriter(writer io.Writer, hasher hash.Hash) *HashingWriter

NewHashingWriter returns a new HashingWriter that wraps the provided writer and the hasher.

Example:

hw := NewHashingWriter(w, sha1.New())
io.Copy(hw, reader)
hash := hw.Base64Sum()

func (*HashingWriter) Base64Sum

func (h *HashingWriter) Base64Sum() string

Base64Sum returns the base64 encoded hash.

func (*HashingWriter) HexSum

func (h *HashingWriter) HexSum() string

HexSum returns the hex-ified checksum.

func (*HashingWriter) Sum

func (h *HashingWriter) Sum() []byte

Sum returns the raw checksum.

func (*HashingWriter) Write

func (h *HashingWriter) Write(data []byte) (int, error)

Write writes to both the wrapped file and the hash.

Jump to

Keyboard shortcuts

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