struct HalfSipHash32(CROUNDS, DROUNDS)

Overview

A streaming version of HalfSipHash with a fixed UInt32 output.

An alternative SipHash pseudorandom function that uses a 64-bit key and generates 32-bit or 64-bit hashes, meant for 32-bit platforms. On 64-bit platform we advise to use SipHash instead.

While SipHash(2, 4) has been analyzed and verified to be cryptographically secure, HalfSipHash has not, and isn't expected to be. Results from the hasher should never be disclosed (e.g. use for table hashing on 32-bit).

See https://131002.net/siphash/ for more information.

Example:

key = uninitialized HalfSipHash32::Key
SecureRandom.random_bytes(key.to_slice)

hasher = HalfSipHash32(2, 4).new(key)
hasher.update("some ")
hasher.update("input data")
hash = hasher.final

Defined in:

halfsiphash32.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(key : Key) #

[View source]

Instance Method Detail

def final(output : Bytes) : Nil #

[View source]
def final #

[View source]
def update(data : String) : Nil #

[View source]
def update(data : Bytes) : Nil #

[View source]