tiger

package
v0.0.0-...-ece3ee3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package tiger provides the Tiger hash.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MagnetLink(name string, size uint64, tth Hash) string

MagnetLink generates a link to a shared file. The link can be shared anywhere and can be opened by most of the available DC clients, starting the download.

func NewHash

func NewHash() hash.Hash

NewHash allocates a tiger hash instance.

Types

type Hash

type Hash godctiger.Hash

Hash is the result of the hash cryptographic function. In particular, it is used to save a Tiger Tree Hash (TTH), the univoque identifier associated to a specific file content.

func HashFromBase32

func HashFromBase32(in string) (Hash, error)

HashFromBase32 imports a Hash in base32 encoding.

func HashFromBytes

func HashFromBytes(in []byte) Hash

HashFromBytes computes the Tiger Tree Hash (TTH) of a byte slice.

func HashFromFile

func HashFromFile(fpath string) (Hash, error)

HashFromFile computes the Tiger Tree Hash (TTH) of a file.

func HashMust

func HashMust(in string) Hash

HashMust is like TTHFromBase32 but panics in case of error.

func (Hash) MarshalText

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

MarshalText implements encoding.TextMarshaler.

func (Hash) String

func (h Hash) String() string

String converts a hash to its base32 representation.

func (*Hash) UnmarshalText

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

UnmarshalText implements encoding.TextUnmarshaler.

type Leaves

type Leaves []Hash

Leaves is a sequence of hashes that can be used to validate the single parts of a file, and ultimately to compute the file TTH.

func LeavesFromBytes

func LeavesFromBytes(in []byte) (Leaves, error)

LeavesFromBytes computes the TTH leaves of a byte slice.

func LeavesFromFile

func LeavesFromFile(fpath string) (Leaves, error)

LeavesFromFile computes the TTH leaves of a file.

func LeavesFromReader

func LeavesFromReader(in io.Reader) (Leaves, error)

LeavesFromReader computes the TTH leaves of data provided by a Reader.

func LeavesLoadFromBytes

func LeavesLoadFromBytes(in []byte) (Leaves, error)

LeavesLoadFromBytes loads TTH leaves from a byte slice. please note that this function does NOT compute TTH leaves of the input data, it just reads the data and use it as TTH leaves.

func LeavesLoadFromFile

func LeavesLoadFromFile(fpath string) (Leaves, error)

LeavesLoadFromFile loads TTH leaves from a file. please note that this function does NOT compute TTH leaves of the input data, it just reads the data and use it as TTH leaves.

func LeavesLoadFromReader

func LeavesLoadFromReader(r io.Reader) (Leaves, error)

LeavesLoadFromReader loads TTH leaves from data provided by a Reader. please note that this function does NOT compute TTH leaves of the input data, it just reads the data and use it as TTH leaves.

func (Leaves) SaveToBytes

func (l Leaves) SaveToBytes() ([]byte, error)

SaveToBytes saves the TTH leaves into a byte slice.

func (Leaves) SaveToFile

func (l Leaves) SaveToFile(fpath string) error

SaveToFile saves the TTH leaves into a file.

func (Leaves) SaveToWriter

func (l Leaves) SaveToWriter(w io.Writer) error

SaveToWriter saves the TTH leaves into a Writer.

func (Leaves) TreeHash

func (l Leaves) TreeHash() Hash

TreeHash converts tiger leaves into a TTH.

Jump to

Keyboard shortcuts

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