hash

package
v0.0.0-...-39c852c Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package hash provides helper functions for file hashing

Index

Constants

View Source
const (
	HASH_TYPE_INVALID = 0
	HASH_TYPE_MD5     = 1 << iota
	HASH_TYPE_SHA1
	HASH_TYPE_SHA256
	HASH_TYPE_SHA512
	HASH_TYPE_XXHASH
	HASH_TYPE_TIGER
)

Variables

View Source
var (
	HashTypeInvalid HashType = ""
	HashTypeMd5     HashType = "md5"
	HashTypeSha1    HashType = "sha1"
	HashTypeSha256  HashType = "sha256"
	HashTypeSha512  HashType = "sha512"
	HashTypeXxhash  HashType = "xxhash"
	HashTypeTiger   HashType = "tiger"

	DefaultHash = HashTypeSha256

	HashTypesAll HashTypeList = HashTypeList{
		HashTypeMd5,
		HashTypeSha1,
		HashTypeSha256,
		HashTypeSha512,
		HashTypeXxhash,
		HashTypeTiger,
	}

	EInvalidHash = errors.New("checksums do not match")
)

Functions

This section is empty.

Types

type HashBlock

type HashBlock struct {
	Md5    string `json:"md5,omitempty"`    // 128bit, 32 digits + 4
	Sha1   string `json:"sha1,omitempty"`   // 160bit, 40 digits + 5
	Sha256 string `json:"sha256,omitempty"` // 256bit, 64 digits + 7
	Sha512 string `json:"sha512,omitempty"` // 512bit, 128 digits + 7
	XXHash string `json:"xxhash,omitempty"` // 64bit, 16 digits + 7
	Tiger  string `json:"tiger,omitempty"`  // 192bit, 48 digits + 6
	// contains filtered or unexported fields
}

func Parse

func Parse(r io.Reader) (HashBlock, error)

func ParseEtag

func ParseEtag(s string) HashBlock

func ParseString

func ParseString(s string) HashBlock

func (*HashBlock) AnyFlag

func (h *HashBlock) AnyFlag() HashFlags

func (HashBlock) Check

func (h HashBlock) Check(h2 HashBlock, ignoreempty bool) error

func (*HashBlock) Clear

func (h *HashBlock) Clear()

func (HashBlock) Clone

func (h HashBlock) Clone(flags HashFlags) HashBlock

func (*HashBlock) Contains

func (h *HashBlock) Contains(l ...HashType) bool

func (*HashBlock) Etag

func (h *HashBlock) Etag() string

func (*HashBlock) EtagHeader

func (h *HashBlock) EtagHeader() string

func (*HashBlock) Flags

func (h *HashBlock) Flags() HashFlags

func (*HashBlock) Get

func (h *HashBlock) Get(key HashType) string

func (*HashBlock) IsZero

func (h *HashBlock) IsZero() bool

func (HashBlock) JsonString

func (h HashBlock) JsonString() string

func (HashBlock) MarshalText

func (r HashBlock) MarshalText() ([]byte, error)

Text/JSON conversion

func (*HashBlock) NewReader

func (h *HashBlock) NewReader(r io.Reader, flags HashFlags) io.Reader

func (*HashBlock) NewWriter

func (h *HashBlock) NewWriter(w io.Writer, flags HashFlags) io.Writer

func (*HashBlock) Parse

func (h *HashBlock) Parse(r io.Reader) error

func (*HashBlock) ParseEtag

func (h *HashBlock) ParseEtag(etag string)

func (*HashBlock) Reset

func (h *HashBlock) Reset()

func (*HashBlock) Scan

func (r *HashBlock) Scan(value interface{}) error

SQL conversion

func (*HashBlock) Set

func (h *HashBlock) Set(key HashType, val string)

func (HashBlock) String

func (h HashBlock) String() string

func (*HashBlock) Sum

func (h *HashBlock) Sum()

func (*HashBlock) UnmarshalText

func (r *HashBlock) UnmarshalText(data []byte) error

func (HashBlock) Value

func (r HashBlock) Value() (driver.Value, error)

type HashFlags

type HashFlags int

func (HashFlags) Contains

func (f HashFlags) Contains(b HashFlags) bool

type HashType

type HashType string

func (HashType) Flag

func (t HashType) Flag() HashFlags

type HashTypeList

type HashTypeList []HashType

func ParseTypeList

func ParseTypeList(s string) HashTypeList

func (*HashTypeList) Add

func (HashTypeList) Contains

func (l HashTypeList) Contains(t HashType) bool

func (HashTypeList) Flags

func (l HashTypeList) Flags() HashFlags

func (HashTypeList) MarshalText

func (r HashTypeList) MarshalText() ([]byte, error)

Text/JSON conversion

func (*HashTypeList) Scan

func (r *HashTypeList) Scan(value interface{}) error

SQL conversion

func (HashTypeList) String

func (l HashTypeList) String() string

func (*HashTypeList) UnmarshalText

func (r *HashTypeList) UnmarshalText(data []byte) error

func (HashTypeList) Value

func (r HashTypeList) Value() (driver.Value, error)

Directories

Path Synopsis
Implements the Tiger/192 hash function as specified in http://www.cs.technion.ac.il/~biham/Reports/Tiger/tiger/tiger.html Tiger/160 and Tiger/128 are simply truncations of the Tiger/192 sum, so there's no specific implementation for those.
Implements the Tiger/192 hash function as specified in http://www.cs.technion.ac.il/~biham/Reports/Tiger/tiger/tiger.html Tiger/160 and Tiger/128 are simply truncations of the Tiger/192 sum, so there's no specific implementation for those.
Package xxhash implements the 64-bit variant of xxHash (XXH64) as described at http://cyan4973.github.io/xxHash/.
Package xxhash implements the 64-bit variant of xxHash (XXH64) as described at http://cyan4973.github.io/xxHash/.

Jump to

Keyboard shortcuts

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