Documentation
¶
Overview ¶
Package feistel implements Feistel network (also kown as Feistel cipher) for bytes slices and integers.
Index ¶
- Variables
- func BytesHash(hasher hash.Hash, rounds int, data []byte) (rv []byte, err error)
- func BytesHashKeys(hasher hash.Hash, keys [][]byte, data []byte) (rv []byte, err error)
- func HashBlock(hasher hash.Hash, rounds int, data []byte) (rv []byte, err error)
- func HashBlockSafe(hasher hash.Hash, rounds int, data []byte) (rv []byte, err error)
- func HashBlockUnsafe(hasher hash.Hash, rounds int, data []byte) (rv []byte)
- func HashKeys(hasher hash.Hash, keys [][]byte, data []byte) (rv []byte, err error)
- func HashKeysSafe(hasher hash.Hash, keys [][]byte, data []byte) (rv []byte, err error)
- func HashKeysUnsafe(hasher hash.Hash, keys [][]byte, data []byte) (rv []byte)
- func Uint64Hash(hasher hash.Hash, rounds int, value uint64) (rv uint64, err error)
- func Uint64HashKeys(hasher hash.Hash, keys [][]byte, value uint64) (rv uint64, err error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadRoundsCount - invalid rounds value. ErrBadRoundsCount = errors.New("rounds value must be > 0") // ErrUnevenDataSize - incoming data size in not even. ErrUnevenDataSize = errors.New("data size must be even") // ErrWrongHasherSize - invalid hasher selected for given data size. ErrWrongHasherSize = errors.New("wrong hasher size - must be half of data size") )
Functions ¶
func BytesHashKeys ¶
BytesHashKeys runs balanced Feistel network for specified bytes slice with given set of keys.
func HashBlock ¶
HashBlock runs balanced Feistel network for specified bytes block its size must be even and twice of hasher size. Please note - this method damages provided data slice, use this if speed matters but original data content is not.
func HashBlockSafe ¶
HashBlockSafe is a safe version of BlockHash method, its slower and uses one more alloc but does not change content of provided data slice, uses this if you need those bytes elsewhere.
func HashBlockUnsafe ¶
HashBlockUnsafe runs balanced Feistel network for specified bytes slice without any bounds checks.
func HashKeys ¶
HashKeys runs balanced Feistel network for specified bytes block with given set of keys. This method damages provided data slice.
func HashKeysSafe ¶
HashKeysSafe is a safe version of BlockKeys method - it does not change incoming data slice.
func HashKeysUnsafe ¶
HashKeysUnsafe runs balanced Feistel network for specified bytes slice with given set of keys without any bounds checks.
func Uint64Hash ¶
Uint64Hash runs Feistel network for specified integer value.
Types ¶
This section is empty.