rclone: github.com/rclone/rclone/fs/hash Index | Files

package hash

import "github.com/rclone/rclone/fs/hash"


Package Files



var ErrUnsupported = errors.New("hash type not supported")

ErrUnsupported should be returned by filesystem, if it is requested to deliver an unsupported hash type.

func Equals Uses

func Equals(src, dst string) bool

Equals checks to see if src == dst, but ignores empty strings and returns true if either is empty.

func Stream Uses

func Stream(r io.Reader) (map[Type]string, error)

Stream will calculate hashes of all supported hash types.

func StreamTypes Uses

func StreamTypes(r io.Reader, set Set) (map[Type]string, error)

StreamTypes will calculate hashes of the requested hash types.

func Width Uses

func Width(hashType Type) int

Width returns the width in characters for any HashType

type MultiHasher Uses

type MultiHasher struct {
    // contains filtered or unexported fields

A MultiHasher will construct various hashes on all incoming writes.

func NewMultiHasher Uses

func NewMultiHasher() *MultiHasher

NewMultiHasher will return a hash writer that will write all supported hash types.

func NewMultiHasherTypes Uses

func NewMultiHasherTypes(set Set) (*MultiHasher, error)

NewMultiHasherTypes will return a hash writer that will write the requested hash types.

func (*MultiHasher) Size Uses

func (m *MultiHasher) Size() int64

Size returns the number of bytes written

func (*MultiHasher) Sums Uses

func (m *MultiHasher) Sums() map[Type]string

Sums returns the sums of all accumulated hashes as hex encoded strings.

func (*MultiHasher) Write Uses

func (m *MultiHasher) Write(p []byte) (n int, err error)

type Set Uses

type Set int

A Set Indicates one or more hash types.

func NewHashSet Uses

func NewHashSet(t ...Type) Set

NewHashSet will create a new hash set with the hash types supplied

func Supported Uses

func Supported() Set

Supported returns a set of all the supported hashes by HashStream and MultiHasher.

func (*Set) Add Uses

func (h *Set) Add(t ...Type) Set

Add one or more hash types to the set. Returns the modified hash set.

func (Set) Array Uses

func (h Set) Array() (ht []Type)

Array returns an array of all hash types in the set

func (Set) Contains Uses

func (h Set) Contains(t Type) bool

Contains returns true if the

func (Set) Count Uses

func (h Set) Count() int

Count returns the number of hash types in the set

func (Set) GetOne Uses

func (h Set) GetOne() Type

GetOne will return a hash type. Currently the first is returned, but it could be improved to return the strongest.

func (Set) Overlap Uses

func (h Set) Overlap(t Set) Set

Overlap returns the overlapping hash types

func (Set) String Uses

func (h Set) String() string

String returns a string representation of the hash set. The function will panic if it contains an unknown type.

func (Set) SubsetOf Uses

func (h Set) SubsetOf(c Set) bool

SubsetOf will return true if all types of h is present in the set c

type Type Uses

type Type int

Type indicates a standard hashing algorithm

var (
    // None indicates no hashes are supported
    None Type

    // MD5 indicates MD5 support
    MD5 Type

    // SHA1 indicates SHA-1 support
    SHA1 Type

    // Whirlpool indicates Whirlpool support
    Whirlpool Type

    // CRC32 indicates CRC-32 support
    CRC32 Type

func RegisterHash Uses

func RegisterHash(name string, width int, newFunc func() hash.Hash) Type

RegisterHash adds a new Hash to the list and returns it Type

func (*Type) Set Uses

func (h *Type) Set(s string) error

Set a Type from a flag

func (Type) String Uses

func (h Type) String() string

String returns a string representation of the hash type. The function will panic if the hash type is unknown.

func (Type) Type Uses

func (h Type) Type() string

Type of the value

Package hash imports 10 packages (graph) and is imported by 156 packages. Updated 2019-10-31. Refresh now. Tools for package owners.