tiger

package
v0.0.0-...-27520ef Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: BSD-3-Clause Imports: 8 Imported by: 2

Documentation

Overview

Package tiger implements Tiger hash function and TTH (Tiger Tree Hash) algorithm.

Index

Constants

View Source
const (
	BlockSize  = 64 // 512 bits
	Size       = 24 // 192 bits
	Base32Size = 39
)

Variables

This section is empty.

Functions

func New

func New() hash.Hash

New returns a new hash.Hash that calculates the Tiger/192 hash digest.

Types

type Hash

type Hash [Size]byte

Hash is a tiger hash value.

func HashBytes

func HashBytes(b []byte) (out Hash)

HashBytes calculates the tiger hash of a byte slice.

func MustParseBase32

func MustParseBase32(s string) (out Hash)

MustParseBase32 parses the tiger hash from base32 encoding and panics on error.

func TreeHash

func TreeHash(r io.Reader) (root Hash, err error)

TreeHash calculates a Tiger Tree Hash of a reader.

func (Hash) Base32

func (h Hash) Base32() string

Base32 returns base32 representation of the hash.

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes returns byte slice from the hash. Same as h[:].

func (*Hash) FromBase32

func (h *Hash) FromBase32(s string) error

FromBase32 parses hash from base32 encoding.

func (Hash) Hex

func (h Hash) Hex() string

Hex returns hexadecimal representation of the hash.

func (Hash) IsZero

func (h Hash) IsZero() bool

IsZero check if hash value is zero.

func (Hash) MarshalADC

func (h Hash) MarshalADC(buf *bytes.Buffer) error

MarshalADC implements adc.Marshaler.

func (Hash) MarshalBase32

func (h Hash) MarshalBase32(buf []byte) error

MarshalBase32 encodes the hash to a given buffer. Buffer should be at least Base32Len.

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Hash) String

func (h Hash) String() string

String returns base32 representation of the hash.

func (*Hash) UnmarshalADC

func (h *Hash) UnmarshalADC(buf []byte) error

UnmarshalADC implements adc.Unmarshaler.

func (*Hash) UnmarshalBase32

func (h *Hash) UnmarshalBase32(buf []byte) error

UnmarshalBase32 decodes the hash from a given buffer.

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Leaves

type Leaves []Hash

Leaves are a sequence of concatenated hashes that can be used to validate the single parts of a certain file.

func TreeLeaves

func TreeLeaves(r io.Reader) (lvl Leaves, err error)

TreeLeaves computes the TTH leaves of a reader.

func (Leaves) TreeHash

func (in Leaves) TreeHash() Hash

TreeHash converts leaves into a hash.

Jump to

Keyboard shortcuts

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