MurmurHash3

Implements the MurmurHash3 functions. You can specify the size of the hash in bit. For 128 bit hashes you can specify whether to optimize for 32 or 64 bit architectures. If you don't specify the opt value it will select the fastest version of the host platform.

This hasher is compatible with the Digest API:

  • void start()
  • void put(scope const(ubyte)[] data...)
  • ubyte[Element.sizeof] finish()

It also provides a faster, low level API working with data of size Element.sizeof:

  • void putElements(scope const(Element[]) elements...)
  • void putRemainder(scope const(ubyte[]) data...)
  • void finalize()
  • Element get()
  • ubyte[Element.sizeof] getBytes()
@safe
struct MurmurHash3 (
uint size
uint opt = size_t.sizeof == 8 ? 64 : 32
) {}

Constructors

this
this(uint seed)
Undocumented in source.
this
this(uint seed4, uint seed3, uint seed2, uint seed1)
Undocumented in source.
this
this(uint seed)
Undocumented in source.
this
this(ulong seed)
Undocumented in source.
this
this(ulong seed2, ulong seed1)
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

Element
alias Element = uint
Undocumented in source.
Element
alias Element = uint[4]
Undocumented in source.
Element
alias Element = ulong[2]
Undocumented in source.
Element
alias Element = char
Undocumented in source.

Functions

finalize
void finalize()

Incorporate element_count and finalizes the hash.

finalize
void finalize()

Incorporate element_count and finalizes the hash.

finalize
void finalize()

Incorporate element_count and finalizes the hash.

finish
ubyte[Element.sizeof] finish()

Finalizes the computation of the hash and returns the computed value. Note that finish can be called only once and that no subsequent calls to put is allowed.

get
Element get()

Returns the hash as an uint value.

get
Element get()

Returns the hash as an uint[4] value.

get
Element get()

Returns the hash as an ulong[2] value.

getBytes
ubyte[4] getBytes()

Returns the current hashed value as an ubyte array.

getBytes
ubyte[16] getBytes()

Returns the current hashed value as an ubyte array.

getBytes
ubyte[16] getBytes()

Returns the current hashed value as an ubyte array.

put
void put(const(ubyte)[] data)

Adds data to the digester. This function can be called many times in a row after start but before finish.

putElement
void putElement(uint block)

Adds a single Element of data without increasing element_count. Make sure to increase element_count by Element.sizeof for each call to putElement.

putElement
void putElement(Element block)

Adds a single Element of data without increasing element_count. Make sure to increase element_count by Element.sizeof for each call to putElement.

putElement
void putElement(Element block)

Adds a single Element of data without increasing element_count. Make sure to increase element_count by Element.sizeof for each call to putElement.

putElements
void putElements(const(Element[]) elements)

Pushes an array of elements at once. It is more efficient to push as much data as possible in a single call. On platforms that do not support unaligned reads (MIPS or old ARM chips), the compiler may produce slower code to ensure correctness.

putRemainder
void putRemainder(const(ubyte[]) data)

Put remainder bytes. This must be called only once after putElement and before finalize.

putRemainder
void putRemainder(const(ubyte[]) data)

Put remainder bytes. This must be called only once after putElement and before finalize.

putRemainder
void putRemainder(const(ubyte[]) data)

Put remainder bytes. This must be called only once after putElement and before finalize.

start
void start()
Undocumented in source. Be warned that the author may not have intended to support it.

Manifest constants

blockSize
enum blockSize;
Undocumented in source.

Variables

element_count
size_t element_count;
Undocumented in source.

Meta