hash

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: Apache-2.0 Imports: 6 Imported by: 9

Documentation

Index

Constants

View Source
const (
	//SHA1 sha1
	SHA1   HashType = 0x10
	SHA2   HashType = 0x20
	SHA3   HashType = 0x30
	KECCAK HashType = 0x40

	Size224 HashType = 0x01
	Size256 HashType = 0x00
	Size384 HashType = 0x02
	Size512 HashType = 0x03

	//SHA2_224 sha2 with 224bits
	SHA2_224 = SHA2 | Size224
	//SHA2_256 sha2 with 224bits
	SHA2_256 = SHA2 | Size256
	//SHA2_384 sha2 with 384bits
	SHA2_384 = SHA2 | Size384
	//SHA2_512 sha2 with 512bits
	SHA2_512 = SHA2 | Size512
	//SHA3_224 sha3 with 224bits
	SHA3_224 = SHA3 | Size224
	//SHA3_256 sha3 with 256bits
	SHA3_256 = SHA3 | Size256
	//SHA3_384 sha3 with 384bits
	SHA3_384 = SHA3 | Size384
	//SHA3_512 sha3 with 512bits
	SHA3_512 = SHA3 | Size512
	//KECCAK_224 KECCAK with 224bits
	KECCAK_224 = KECCAK | Size224
	//KECCAK_256 KECCAK with 256bits
	KECCAK_256 = KECCAK | Size256
	//KECCAK_384 KECCAK with 384bits
	KECCAK_384 = KECCAK | Size384
	//KECCAK_512 KECCAK with 512bits
	KECCAK_512 = KECCAK | Size512
)

nolint

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeHasher

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

FakeHasher thw return value of function FakeHasher

func GetFakeHasher

func GetFakeHasher() *FakeHasher

GetFakeHasher get hasher

func (*FakeHasher) BatchHash

func (f *FakeHasher) BatchHash(msg [][]byte) (hash []byte, err error)

BatchHash hash with two-dimensional array

func (*FakeHasher) BlockSize

func (f *FakeHasher) BlockSize() int

BlockSize hash block size

func (*FakeHasher) Hash

func (f *FakeHasher) Hash(msg []byte) (hash []byte, err error)

Hash compute hash

func (*FakeHasher) Reset

func (f *FakeHasher) Reset()

Reset reset state

func (*FakeHasher) Size

func (f *FakeHasher) Size() int

Size size

func (*FakeHasher) Sum

func (f *FakeHasher) Sum(b []byte) []byte

Sum hash sum

func (*FakeHasher) Write

func (f *FakeHasher) Write(p []byte) (n int, err error)

Write write data

type HashType

type HashType uint32

HashType represent hash algorithm type

type Hasher

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

Hasher thw return value of function NewHasher

func NewHasher

func NewHasher(hashType HashType) *Hasher

NewHasher instruct a Hasher, the incoming parameter is the algorithm type.

func (*Hasher) BatchHash

func (h *Hasher) BatchHash(msg [][]byte) (hash []byte, err error)

BatchHash hash with two-dimensional array

func (*Hasher) BlockSize

func (h *Hasher) BlockSize() int

BlockSize hash block size

func (*Hasher) Hash

func (h *Hasher) Hash(msg []byte) (hash []byte, err error)

Hash compute hash

func (*Hasher) HashBuffer

func (h *Hasher) HashBuffer(msg []byte, buf []byte) (hash []byte, err error)

HashBuffer is identical to Hash except that it stages through the provided buffer (if one is required) rather than allocating a temporary one. If buf is nil or has un-expected size, one fix-sized bytes will be allocated.

func (*Hasher) Reset

func (h *Hasher) Reset()

Reset reset state

func (*Hasher) Size

func (h *Hasher) Size() int

Size hash size

func (*Hasher) Sum

func (h *Hasher) Sum(b []byte) []byte

Sum get sum

func (*Hasher) Write

func (h *Hasher) Write(p []byte) (n int, err error)

Write write data

Directories

Path Synopsis
Hyperchain License Copyright (C) 2016 The Hyperchain Authors.
Hyperchain License Copyright (C) 2016 The Hyperchain Authors.

Jump to

Keyboard shortcuts

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