hasher

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedAlgorithms = map[string]algorithm{
	"blake2b":     blake2b.New512,
	"blake2b-256": blake2b.New256,
	"blake2b-384": blake2b.New384,
	"blake2b-512": blake2b.New512,
	"blake2s-128": blake2s.New128,
	"blake2s-256": blake2s.New256,
	"blake3":      newBlake3Hash,
	"blake3-dk":   newBlake3DerivedKey,
	"crc32":       crc32.NewIEEE,
	"md5":         md5.New,
	"sha1":        sha1.New,
	"sha224":      sha256.New224,
	"sha256":      sha256.New,
	"sha256-simd": sha256simd.New,
	"sha384":      sha512.New384,
	"sha512":      sha512.New,
	"sha3-224":    sha3.New224,
	"sha3-256":    sha3.New256,
	"sha3-384":    sha3.New384,
	"sha3-512":    sha3.New512,
	"skein-256":   algoSize{skein.NewMAC, 256 / 8},
	"skein-512":   algoSize{skein.NewMAC, 512 / 8},
}

SupportedAlgorithms maps algorithm names to implementations

Functions

func HashRouter

func HashRouter(input <-chan FileHash, hashOutput, nilOutput chan<- FileHash, wg *sync.WaitGroup)

HashRouter splits an input FileHash channel into separate outputs based upon whether the item Hash is nil

func HashSink

func HashSink(input <-chan FileHash, wg *sync.WaitGroup)

HashSink blackholes items from a FileHash channel

func OutputProtobufFile

func OutputProtobufFile(input <-chan *FileHash, wg *sync.WaitGroup)

OutputProtobufFile goroutine

func OutputTextFile

func OutputTextFile(input <-chan *FileHash, wg *sync.WaitGroup)

OutputTextFile goroutine

func SortByFifo

func SortByFifo(input <-chan *FileHash, output chan<- *FileHash, wg *sync.WaitGroup)

SortByFifo takes an input channel of FileHash and adds each item directly to the output in the order received

func SortByPath

func SortByPath(input <-chan *FileHash, output chan<- *FileHash, wg *sync.WaitGroup)

SortByPath takes an input channel of FileHash and lexicographically sorts by file path

func Sprintf

func Sprintf(format string, item *FileHash) string

Sprintf returns a formatted string representation of FileHash

Types

type FileHash

type FileHash struct {
	File     *pathwalk.File
	Hash     []byte
	AttrInfo struct {
		Hash []byte
		Time time.Time
	}
	FileInfo struct {
		Hash []byte
		Time time.Time
	}
	Type string
}

FileHash type

type Hasher

type Hasher struct {
	Type string
	Hash hash.Hash
}

func New

func New(algo string, key []byte) Hasher

New returns an initialised instance of the appropriate hash function

func (*Hasher) HashFile

func (hasher *Hasher) HashFile(file *pathwalk.File) *FileHash

HashFile calculates the hash/hmac of file at path

func (*Hasher) HashIoReader

func (hasher *Hasher) HashIoReader(reader io.Reader) []byte

HashIoReader calculates the hash/hmac of stdin

func (*Hasher) HashProcessor

func (hasher *Hasher) HashProcessor(input <-chan *pathwalk.File, output chan<- *FileHash, wg *sync.WaitGroup)

HashProcessor goroutine

Jump to

Keyboard shortcuts

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