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

package hash

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

Index

Package Files

hash.go

Variables

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

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

var Supported = NewHashSet(MD5, SHA1, Dropbox, QuickXorHash)

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

var Width = map[Type]int{
    MD5:          32,
    SHA1:         40,
    Dropbox:      64,
    QuickXorHash: 40,
}

Width returns the width in characters for any HashType

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.

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 (*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

const (
    // MD5 indicates MD5 support
    MD5 Type = 1 << iota

    // SHA1 indicates SHA-1 support
    SHA1

    // Dropbox indicates Dropbox special hash
    // https://www.dropbox.com/developers/reference/content-hash
    Dropbox

    // QuickXorHash indicates Microsoft onedrive hash
    // https://docs.microsoft.com/en-us/onedrive/developer/code-snippets/quickxorhash
    QuickXorHash

    // None indicates no hashes are supported
    None Type = 0
)

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 78 packages. Updated 2019-02-09. Refresh now. Tools for package owners.