hash

package
v0.0.0-...-19e16ce Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BinprintHighwayKey = []byte{0xed, 0x73, 0xad, 0xab, 0x57, 0xd, 0x4f, 0x16, 0xc8, 0xd0, 0xa8, 0xac, 0x81, 0x47, 0x4a, 0xe3, 0xd5, 0xf8, 0x7f, 0x8, 0x7d, 0xfd, 0xcb, 0x91, 0x90, 0x94, 0x3a, 0x66, 0xfd, 0xf0, 0x40, 0xd6}

BinprintHighwayKey is the hashing key used by all binprint hashes calculated with the Highway Hash algorithm

Functions

This section is empty.

Types

type AsyncHash

type AsyncHash interface {
	hash.Hash
	io.Closer
	Digest() Digest
	Done() <-chan Digest
}

AsyncHash is a wrapper for hash.Hash that operates asynchronously by using a buffering pipe to accept input and a channel to provide the final digest

func NewAsyncHash

func NewAsyncHash(algorithm string, size int64) (AsyncHash, error)

NewAsyncHash returns an AsyncHash that implements the requested hash. Only some algorithms require knowing the size of the input first (git sha1).

type BasicHasher

type BasicHasher struct {
	hash.Hash
	// contains filtered or unexported fields
}

BasicHasher is a hash.AsyncHasher that calculates a sha1sum using the same salting mechanism as git does when storing blob objects

func (BasicHasher) Close

func (sh BasicHasher) Close() error

Close closes the underlying pipe and finalizes the hash

func (BasicHasher) Digest

func (sh BasicHasher) Digest() Digest

Digest returns the calculated Digest. This consumes the channel returned by Done(), but will always return the same Digest afterwards.

func (BasicHasher) Done

func (sh BasicHasher) Done() <-chan Digest

Done returns a Digest channel, satisfying the AsyncHasher interface

func (BasicHasher) Write

func (sh BasicHasher) Write(bytes []byte) (int, error)

Write adds the given slice to the internal Hash

type Digest

type Digest interface {
	// A Digest is a hash.Hash that has already been finalized and is
	// essentially a wrapper around the fixed length checksum result
	// hash.Hash
	Sum(b []byte) []byte
	// Reset()
	Size() int

	// IsZero returns true for Digests that are the zero-value of their type
	// (aka, all 0s)
	IsZero() bool

	// String returns the hex string representing the checksum
	String() string

	// Base64 returns the checksum as a base64 string
	Base64() string

	// Bytes returns the finalized checksum bytes, similar to Sum(), but
	// simplified for hashes that have already been finalized
	Bytes() []byte
}

Digest is a finalized hash.Hash. It conforms to the hash.Hash interface, but it does not support operations that modify the finalized checksum

type DigestMatcher

type DigestMatcher struct {
	P string
	T string
	B []byte
}

DigestMatcher is a multi-hash comparison operand allowing Digest objects to be matched against.

func NewDigestMatcher

func NewDigestMatcher(pat string) (DigestMatcher, error)

NewDigestMatcher creates a new DigestMatcher by parsing the provided string

func (DigestMatcher) Match

func (matcher DigestMatcher) Match(hash Digest) bool

Match compares the DigestMatcher against a given Digest, either by string representation or direct byte comparison if the provided string was an even number of hex digits.

type GitShaDigest

type GitShaDigest struct {
	// contains filtered or unexported fields
}

GitShaDigest is the variant of sha1 used by Git to identify blobs

func GitShaDigestFromRaw

func GitShaDigestFromRaw(raw [20]byte) GitShaDigest

func NewGitShaDigest

func NewGitShaDigest(h hash.Hash) *GitShaDigest

func (GitShaDigest) Base64

func (d GitShaDigest) Base64() string

func (GitShaDigest) BlockSize

func (GitShaDigest) BlockSize() int

func (GitShaDigest) Bytes

func (d GitShaDigest) Bytes() []byte

func (GitShaDigest) IsZero

func (d GitShaDigest) IsZero() bool

func (*GitShaDigest) MarshalBinary

func (d *GitShaDigest) MarshalBinary() ([]byte, error)

func (GitShaDigest) MarshalYAML

func (d GitShaDigest) MarshalYAML() (interface{}, error)

func (d digest160) Len() int { return len(d) }

func (GitShaDigest) Raw

func (d GitShaDigest) Raw() [20]byte

func (GitShaDigest) Reset

func (GitShaDigest) Reset()

func (GitShaDigest) Size

func (d GitShaDigest) Size() int

func (GitShaDigest) String

func (d GitShaDigest) String() string

func (GitShaDigest) Sum

func (d GitShaDigest) Sum(in []byte) []byte

func (GitShaDigest) Sum64

func (d GitShaDigest) Sum64() uint64

func (*GitShaDigest) UnmarshalBinary

func (d *GitShaDigest) UnmarshalBinary(data []byte) error

func (*GitShaDigest) UnmarshalYAML

func (d *GitShaDigest) UnmarshalYAML(unmarshal func(interface{}) error) error

func (GitShaDigest) Write

func (GitShaDigest) Write([]byte) (int, error)

func (d digest128) SRI() string { return fmtSRI(d.TypeName(), d[:]) }

type GitShaHasher

type GitShaHasher struct {
	BasicHasher
	// contains filtered or unexported fields
}

GitShaHasher is a hash.AsyncHasher that calculates a sha1sum using the same salting mechanism as git does when storing blob objects

func NewGitShaHasher

func NewGitShaHasher(oType string, size int64) *GitShaHasher

NewGitShaHasher returns a hash.Hash that will compute a variant sha1 digest as though the input was a git blob object

func (*GitShaHasher) Close

func (gh *GitShaHasher) Close() error

func (*GitShaHasher) Done

func (gh *GitShaHasher) Done() <-chan Digest

func (*GitShaHasher) Write

func (gh *GitShaHasher) Write(bytes []byte) (int, error)

type Highway128Digest

type Highway128Digest struct {
	// contains filtered or unexported fields
}

func NewHighway128Digest

func NewHighway128Digest(h hash.Hash) Highway128Digest

func (Highway128Digest) Base64

func (d Highway128Digest) Base64() string

func (Highway128Digest) Bytes

func (d Highway128Digest) Bytes() []byte

func (Highway128Digest) IsZero

func (d Highway128Digest) IsZero() bool

func (*Highway128Digest) MarshalBinary

func (d *Highway128Digest) MarshalBinary() ([]byte, error)

func (Highway128Digest) MarshalYAML

func (d Highway128Digest) MarshalYAML() (interface{}, error)

func (d digest128) Len() int { return len(d) }

func (Highway128Digest) SRI

func (d Highway128Digest) SRI() string

func (Highway128Digest) Size

func (d Highway128Digest) Size() int

func (digest128) BlockSize() int { defer panic("Unimplemented"); return 0 }

func (Highway128Digest) String

func (d Highway128Digest) String() string

func (Highway128Digest) Sum

func (d Highway128Digest) Sum(in []byte) []byte

func (Highway128Digest) TypeName

func (Highway128Digest) TypeName() string

func (*Highway128Digest) UnmarshalBinary

func (d *Highway128Digest) UnmarshalBinary(data []byte) error

func (*Highway128Digest) UnmarshalYAML

func (d *Highway128Digest) UnmarshalYAML(unmarshal func(interface{}) error) error

type Highway128Hasher

type Highway128Hasher struct {
	BasicHasher
}

func NewHighway128Hasher

func NewHighway128Hasher() Highway128Hasher

type Highway256Digest

type Highway256Digest struct {
	// contains filtered or unexported fields
}

func NewHighway256Digest

func NewHighway256Digest(h hash.Hash) Highway256Digest

func (Highway256Digest) Base64

func (d Highway256Digest) Base64() string

func (Highway256Digest) BlockSize

func (Highway256Digest) BlockSize() int

func (Highway256Digest) Bytes

func (d Highway256Digest) Bytes() []byte

func (Highway256Digest) IsZero

func (d Highway256Digest) IsZero() bool

func (*Highway256Digest) MarshalBinary

func (d *Highway256Digest) MarshalBinary() ([]byte, error)

func (Highway256Digest) MarshalYAML

func (d Highway256Digest) MarshalYAML() (interface{}, error)

func (d digest256) Len() int { return len(d) }

func (Highway256Digest) Reset

func (Highway256Digest) Reset()

func (Highway256Digest) SRI

func (d Highway256Digest) SRI() string

func (Highway256Digest) Size

func (d Highway256Digest) Size() int

func (Highway256Digest) String

func (d Highway256Digest) String() string

func (Highway256Digest) Sum

func (d Highway256Digest) Sum(in []byte) []byte

func (Highway256Digest) TypeName

func (Highway256Digest) TypeName() string

func (*Highway256Digest) UnmarshalBinary

func (d *Highway256Digest) UnmarshalBinary(data []byte) error

func (*Highway256Digest) UnmarshalYAML

func (d *Highway256Digest) UnmarshalYAML(unmarshal func(interface{}) error) error

func (Highway256Digest) Write

func (Highway256Digest) Write([]byte) (int, error)

type Highway256Hasher

type Highway256Hasher struct {
	BasicHasher
}

func NewHighway256Hasher

func NewHighway256Hasher() Highway256Hasher

type Highway64Digest

type Highway64Digest struct {
	// contains filtered or unexported fields
}

func NewHighway64Digest

func NewHighway64Digest(h hash.Hash) Highway64Digest

func (Highway64Digest) Base64

func (d Highway64Digest) Base64() string

func (Highway64Digest) BlockSize

func (Highway64Digest) BlockSize() int

func (Highway64Digest) Bytes

func (d Highway64Digest) Bytes() []byte

func (Highway64Digest) IsZero

func (d Highway64Digest) IsZero() bool

func (*Highway64Digest) MarshalBinary

func (d *Highway64Digest) MarshalBinary() ([]byte, error)

func (Highway64Digest) MarshalYAML

func (d Highway64Digest) MarshalYAML() (interface{}, error)

func (d digest64) Len() int { return len(d) }

func (Highway64Digest) Reset

func (Highway64Digest) Reset()

func (Highway64Digest) SRI

func (d Highway64Digest) SRI() string

func (Highway64Digest) Size

func (Highway64Digest) Size() int

func (Highway64Digest) String

func (d Highway64Digest) String() string

func (Highway64Digest) Sum

func (d Highway64Digest) Sum(in []byte) []byte

func (Highway64Digest) Sum64

func (d Highway64Digest) Sum64() uint64

Sum64 satisfies the hash.Hash64 interface

func (Highway64Digest) TypeName

func (Highway64Digest) TypeName() string

func (*Highway64Digest) UnmarshalBinary

func (d *Highway64Digest) UnmarshalBinary(data []byte) error

func (*Highway64Digest) UnmarshalYAML

func (d *Highway64Digest) UnmarshalYAML(unmarshal func(interface{}) error) error

func (Highway64Digest) Write

func (Highway64Digest) Write([]byte) (int, error)

type Highway64Hasher

type Highway64Hasher struct {
	BasicHasher
}

Highway64Hasher implements HighwayHash64 using the AsyncHasher interface, which is a superset of the hash.Hash interface

func NewHighway64Hasher

func NewHighway64Hasher() Highway64Hasher

func (Highway64Hasher) Sum64

func (h Highway64Hasher) Sum64() uint64

type MD5Digest

type MD5Digest struct {
	// contains filtered or unexported fields
}

func NewMD5Digest

func NewMD5Digest(h hash.Hash) MD5Digest

func (MD5Digest) Base64

func (d MD5Digest) Base64() string

func (MD5Digest) Bytes

func (d MD5Digest) Bytes() []byte

func (MD5Digest) IsZero

func (d MD5Digest) IsZero() bool

func (*MD5Digest) MarshalBinary

func (d *MD5Digest) MarshalBinary() ([]byte, error)

func (MD5Digest) MarshalYAML

func (d MD5Digest) MarshalYAML() (interface{}, error)

func (d digest128) Len() int { return len(d) }

func (MD5Digest) SRI

func (md5 MD5Digest) SRI() string

func (MD5Digest) Size

func (d MD5Digest) Size() int

func (digest128) BlockSize() int { defer panic("Unimplemented"); return 0 }

func (MD5Digest) String

func (d MD5Digest) String() string

func (MD5Digest) Sum

func (d MD5Digest) Sum(in []byte) []byte

func (MD5Digest) TypeName

func (MD5Digest) TypeName() string

func (*MD5Digest) UnmarshalBinary

func (d *MD5Digest) UnmarshalBinary(data []byte) error

func (*MD5Digest) UnmarshalYAML

func (d *MD5Digest) UnmarshalYAML(unmarshal func(interface{}) error) error

type MD5Hasher

type MD5Hasher struct {
	BasicHasher
}

func NewMD5Hasher

func NewMD5Hasher() MD5Hasher

NewMD5Hasher creates a new async hasher for generating md5sums

type SHA1Digest

type SHA1Digest struct {
	// contains filtered or unexported fields
}

func NewSHA1Digest

func NewSHA1Digest(h hash.Hash) SHA1Digest

func (SHA1Digest) Base64

func (d SHA1Digest) Base64() string

func (SHA1Digest) BlockSize

func (SHA1Digest) BlockSize() int

func (SHA1Digest) Bytes

func (d SHA1Digest) Bytes() []byte

func (SHA1Digest) IsZero

func (d SHA1Digest) IsZero() bool

func (*SHA1Digest) MarshalBinary

func (d *SHA1Digest) MarshalBinary() ([]byte, error)

func (SHA1Digest) MarshalYAML

func (d SHA1Digest) MarshalYAML() (interface{}, error)

func (d digest160) Len() int { return len(d) }

func (SHA1Digest) Reset

func (SHA1Digest) Reset()

func (SHA1Digest) SRI

func (sha1 SHA1Digest) SRI() string

func (SHA1Digest) Size

func (d SHA1Digest) Size() int

func (SHA1Digest) String

func (d SHA1Digest) String() string

func (SHA1Digest) Sum

func (d SHA1Digest) Sum(in []byte) []byte

func (SHA1Digest) TypeName

func (SHA1Digest) TypeName() string

func (*SHA1Digest) UnmarshalBinary

func (d *SHA1Digest) UnmarshalBinary(data []byte) error

func (*SHA1Digest) UnmarshalYAML

func (d *SHA1Digest) UnmarshalYAML(unmarshal func(interface{}) error) error

func (SHA1Digest) Write

func (SHA1Digest) Write([]byte) (int, error)

func (d digest128) SRI() string { return fmtSRI(d.TypeName(), d[:]) }

type SHA1Hasher

type SHA1Hasher struct {
	BasicHasher
}

func NewSHA1Hasher

func NewSHA1Hasher() SHA1Hasher

NewSHA1Hasher creates a new async hasher for generating sha1sums

type SHA256Digest

type SHA256Digest struct {
	// contains filtered or unexported fields
}

func NewSHA256Digest

func NewSHA256Digest(h hash.Hash) SHA256Digest

func (SHA256Digest) Base64

func (d SHA256Digest) Base64() string

func (SHA256Digest) BlockSize

func (SHA256Digest) BlockSize() int

func (SHA256Digest) Bytes

func (d SHA256Digest) Bytes() []byte

func (SHA256Digest) IsZero

func (d SHA256Digest) IsZero() bool

func (*SHA256Digest) MarshalBinary

func (d *SHA256Digest) MarshalBinary() ([]byte, error)

func (SHA256Digest) MarshalYAML

func (d SHA256Digest) MarshalYAML() (interface{}, error)

func (d digest256) Len() int { return len(d) }

func (SHA256Digest) Reset

func (SHA256Digest) Reset()

func (SHA256Digest) SRI

func (sha256 SHA256Digest) SRI() string

func (SHA256Digest) Size

func (d SHA256Digest) Size() int

func (SHA256Digest) String

func (d SHA256Digest) String() string

func (SHA256Digest) Sum

func (d SHA256Digest) Sum(in []byte) []byte

func (SHA256Digest) TypeName

func (SHA256Digest) TypeName() string

func (*SHA256Digest) UnmarshalBinary

func (d *SHA256Digest) UnmarshalBinary(data []byte) error

func (*SHA256Digest) UnmarshalYAML

func (d *SHA256Digest) UnmarshalYAML(unmarshal func(interface{}) error) error

func (SHA256Digest) Write

func (SHA256Digest) Write([]byte) (int, error)

type SHA256Hasher

type SHA256Hasher struct {
	BasicHasher
}

func NewSHA256Hasher

func NewSHA256Hasher() SHA256Hasher

NewSHA256Hasher creates a new async hasher for generating sha256sums

type SHA384Digest

type SHA384Digest struct {
	// contains filtered or unexported fields
}

func NewSHA384Digest

func NewSHA384Digest(h hash.Hash) SHA384Digest

func (SHA384Digest) Base64

func (d SHA384Digest) Base64() string

func (SHA384Digest) BlockSize

func (SHA384Digest) BlockSize() int

func (SHA384Digest) Bytes

func (d SHA384Digest) Bytes() []byte

func (SHA384Digest) IsZero

func (d SHA384Digest) IsZero() bool

func (*SHA384Digest) MarshalBinary

func (d *SHA384Digest) MarshalBinary() ([]byte, error)

func (SHA384Digest) MarshalYAML

func (d SHA384Digest) MarshalYAML() (interface{}, error)

func (d digest384) Len() int { return len(d) }

func (SHA384Digest) Reset

func (SHA384Digest) Reset()

func (SHA384Digest) SRI

func (sha384 SHA384Digest) SRI() string

func (SHA384Digest) Size

func (d SHA384Digest) Size() int

func (SHA384Digest) String

func (d SHA384Digest) String() string

func (SHA384Digest) Sum

func (d SHA384Digest) Sum(in []byte) []byte

func (SHA384Digest) TypeName

func (SHA384Digest) TypeName() string

func (*SHA384Digest) UnmarshalBinary

func (d *SHA384Digest) UnmarshalBinary(data []byte) error

func (*SHA384Digest) UnmarshalYAML

func (d *SHA384Digest) UnmarshalYAML(unmarshal func(interface{}) error) error

func (SHA384Digest) Write

func (SHA384Digest) Write([]byte) (int, error)

func (d digest256) SRI() string { return fmtSRI(d.TypeName(), d[:]) }

type SHA384Hasher

type SHA384Hasher struct {
	BasicHasher
}

func NewSHA384Hasher

func NewSHA384Hasher() SHA384Hasher

NewSHA384Hasher creates a new async hasher for generating sha384sums

type SHA512Digest

type SHA512Digest struct {
	// contains filtered or unexported fields
}

SHA512Digest is a finalized SHA512 checksum

func NewSHA512Digest

func NewSHA512Digest(h hash.Hash) SHA512Digest

func (SHA512Digest) Base64

func (d SHA512Digest) Base64() string

func (SHA512Digest) BlockSize

func (SHA512Digest) BlockSize() int

func (SHA512Digest) Bytes

func (d SHA512Digest) Bytes() []byte

func (SHA512Digest) IsZero

func (d SHA512Digest) IsZero() bool

func (*SHA512Digest) MarshalBinary

func (d *SHA512Digest) MarshalBinary() ([]byte, error)

func (SHA512Digest) MarshalYAML

func (d SHA512Digest) MarshalYAML() (interface{}, error)

func (d digest512) Len() int { return len(d) }

func (SHA512Digest) Reset

func (SHA512Digest) Reset()

func (SHA512Digest) SRI

func (sha SHA512Digest) SRI() string

func (SHA512Digest) Size

func (d SHA512Digest) Size() int

func (SHA512Digest) String

func (d SHA512Digest) String() string

func (SHA512Digest) Sum

func (d SHA512Digest) Sum(in []byte) []byte

func (SHA512Digest) TypeName

func (SHA512Digest) TypeName() string

TypeName returns the canonical short name of the digest type

func (*SHA512Digest) UnmarshalBinary

func (d *SHA512Digest) UnmarshalBinary(data []byte) error

func (*SHA512Digest) UnmarshalYAML

func (d *SHA512Digest) UnmarshalYAML(unmarshal func(interface{}) error) error

func (SHA512Digest) Write

func (SHA512Digest) Write([]byte) (int, error)

func (d digest384) SRI() string { return fmtSRI(d.TypeName(), d[:]) }

type SHA512Hasher

type SHA512Hasher struct {
	BasicHasher
}

func NewSHA512Hasher

func NewSHA512Hasher() SHA512Hasher

NewSHA512Hasher creates a new async hasher for generating sha512sums

Jump to

Keyboard shortcuts

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