Documentation ¶
Index ¶
Constants ¶
This section is empty.
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, Whirlpool, CRC32)
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, Whirlpool: 128, CRC32: 8, }
Width returns the width in characters for any HashType
Functions ¶
func Equals ¶
Equals checks to see if src == dst, but ignores empty strings and returns true if either is empty.
Types ¶
type MultiHasher ¶
type MultiHasher struct {
// contains filtered or unexported fields
}
A MultiHasher will construct various hashes on all incoming writes.
func NewMultiHasher ¶
func NewMultiHasher() *MultiHasher
NewMultiHasher will return a hash writer that will write all supported hash types.
func NewMultiHasherTypes ¶
func NewMultiHasherTypes(set Set) (*MultiHasher, error)
NewMultiHasherTypes will return a hash writer that will write the requested hash types.
func (*MultiHasher) Size ¶
func (m *MultiHasher) Size() int64
Size returns the number of bytes written
func (*MultiHasher) Sums ¶
func (m *MultiHasher) Sums() map[Type]string
Sums returns the sums of all accumulated hashes as hex encoded strings.
type Set ¶
type Set int
A Set Indicates one or more hash types.
func NewHashSet ¶
NewHashSet will create a new hash set with the hash types supplied
func (Set) GetOne ¶
GetOne will return a hash type. Currently the first is returned, but it could be improved to return the strongest.
type Type ¶
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 // Whirlpool indicates Whirlpool support Whirlpool // CRC32 indicates CRC-32 support CRC32 // None indicates no hashes are supported None Type = 0 )