hash

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: ISC Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const HashStringSize = ShaSize * 2

HashStringSize is the maximum length of a ShaHash hash string.

View Source
const RipeHashStringSize = RipeSize * 2

RipeHashStringSize is the maximum length of a Ripe hash string.

View Source
const RipeSize = 20

RipeSize is the size of array used to store ripe hashes.

View Source
const ShaSize = 32

ShaSize is the size of the array used to store SHA hashes.

Variables

View Source
var ErrHashStrSize = fmt.Errorf("string length must be %v chars", HashStringSize)

ErrHashStrSize describes an error that indicates the caller specified a hash string that does not have the right number of characters.

View Source
var ErrRipeHashStrSize = fmt.Errorf("string length must be %v chars", RipeHashStringSize)

ErrRipeHashStrSize describes an error that indicates the caller specified a hash string that does not have the right number of characters.

Functions

func DoubleSha512

func DoubleSha512(b []byte) []byte

DoubleSha512 returns the sha512^2 of the bytes

func Sha512

func Sha512(b []byte) []byte

Sha512 returns the sha512 of the bytes

Types

type Ripe

type Ripe [RipeSize]byte

Ripe is used in several of the bitmessage messages and common structures. It typically represents the double sha512 of ripemd160 of data.

func NewRipe

func NewRipe(newHash []byte) (*Ripe, error)

NewRipe returns a new Ripe from a byte slice. An error is returned if the number of bytes passed in is not RipeSize.

func NewRipeFromStr

func NewRipeFromStr(hash string) (*Ripe, error)

NewRipeFromStr creates a Ripe from a hash string. The string should be the hexadecimal string of a byte hash.

func (*Ripe) Bytes

func (hash *Ripe) Bytes() []byte

Bytes returns the bytes which represent the hash as a byte slice.

func (*Ripe) IsEqual

func (hash *Ripe) IsEqual(target *Ripe) bool

IsEqual returns true if target is the same as hash.

func (*Ripe) SetBytes

func (hash *Ripe) SetBytes(newHash []byte) error

SetBytes sets the bytes which represent the hash. An error is returned if the number of bytes passed in is not RipeSize.

func (Ripe) String

func (hash Ripe) String() string

String returns the Ripe as the hexadecimal string of the byte-reversed hash.

type Sha

type Sha [ShaSize]byte

Sha is used in several of the bitmessage messages and common structures. It typically represents a half of the double SHA512 of data.

func InventoryHash

func InventoryHash(stuff []byte) *Sha

InventoryHash takes double sha512 of the bytes and returns the first half. It calculates inventory hash of the object as required by the protocol.

func NewSha

func NewSha(newHash []byte) (*Sha, error)

NewSha returns a new ShaHash from a byte slice. An error is returned if the number of bytes passed in is not ShaHash.

func NewShaFromStr

func NewShaFromStr(hash string) (*Sha, error)

NewShaFromStr creates a ShaHash from a hash string. The string should be the hexadecimal string of a hash.

func (*Sha) Bytes

func (hash *Sha) Bytes() []byte

Bytes returns the bytes which represent the hash as a byte slice.

func (*Sha) IsEqual

func (hash *Sha) IsEqual(target *Sha) bool

IsEqual returns true if target is the same as hash.

func (*Sha) SetBytes

func (hash *Sha) SetBytes(newHash []byte) error

SetBytes sets the bytes which represent the hash. An error is returned if the number of bytes passed in is not ShaSize.

func (Sha) String

func (hash Sha) String() string

String returns the ShaHash as the hexadecimal string of the byte-reversed hash.

Jump to

Keyboard shortcuts

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