hashing

package
v0.3.0-docs.0...-f96dd80 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package hashing implements different hashers and their funcionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Digest

type Digest []byte

type FakeHasher

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

FakeHasher implements the Hasher interface and computes a hash function depending on the caller. Here, 'Salted' function does nothing but act as a passthrough to 'Do' function. Handy for testing hash tree implementations.

func (*FakeHasher) Do

func (h *FakeHasher) Do(data ...[]byte) Digest

Do function hashes input data using the hashing function given by the KeyHasher.

func (FakeHasher) Len

func (h FakeHasher) Len() uint16

Len function returns the size of the resulting hash.

func (*FakeHasher) Salted

func (h *FakeHasher) Salted(salt []byte, data ...[]byte) Digest

Salted function directly hashes data, similarly to Do function.

type Hasher

type Hasher interface {
	Salted([]byte, ...[]byte) Digest
	Do(...[]byte) Digest
	Len() uint16
}

func NewBlake2bHasher

func NewBlake2bHasher() Hasher

NewBlake2bHasher implements the Hasher interface and computes a 256 bit hash function using the Blake2 hashing algorithm.

func NewFakePearsonHasher

func NewFakePearsonHasher() Hasher

func NewFakeSha256Hasher

func NewFakeSha256Hasher() Hasher

func NewFakeXorHasher

func NewFakeXorHasher() Hasher

func NewPearsonHasher

func NewPearsonHasher() Hasher

func NewSha256Hasher

func NewSha256Hasher() Hasher

NewSha256Hasher implements the Hasher interface and computes a 256 bit hash function using the SHA256 hashing algorithm.

func NewXorHasher

func NewXorHasher() Hasher

type KeyHasher

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

func (*KeyHasher) Do

func (s *KeyHasher) Do(data ...[]byte) Digest

Do function hashes input data using the hashing function given by the KeyHasher.

func (KeyHasher) Len

func (s KeyHasher) Len() uint16

Len function returns the size of the resulting hash.

func (*KeyHasher) Salted

func (s *KeyHasher) Salted(salt []byte, data ...[]byte) Digest

Salted function adds a seed to the input data before hashing it.

type PearsonHasher

type PearsonHasher struct{}

PearsonHasher implements the Hasher interface and computes a 8 bit hash function. Handy for testing hash tree implementations.

func (*PearsonHasher) Do

func (p *PearsonHasher) Do(data ...[]byte) Digest

Do function hashes input data using the Pearson hash function.

func (PearsonHasher) Len

func (p PearsonHasher) Len() uint16

Len function returns the size of the resulting hash.

func (*PearsonHasher) Salted

func (h *PearsonHasher) Salted(salt []byte, data ...[]byte) Digest

Salted function adds a seed to the input data before hashing it.

type XorHasher

type XorHasher struct{}

XorHasher implements the Hasher interface and computes a 2 bit hash function. Handy for testing hash tree implementations.

func (XorHasher) Do

func (x XorHasher) Do(data ...[]byte) Digest

Do function hashes input data using the XOR hash function.

func (XorHasher) Len

func (s XorHasher) Len() uint16

Len function returns the size of the resulting hash.

func (XorHasher) Salted

func (x XorHasher) Salted(salt []byte, data ...[]byte) Digest

Salted function adds a seed to the input data before hashing it.

Jump to

Keyboard shortcuts

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