org.apache.commons.codec.digest

## Class MurmurHash2

- java.lang.Object
- - org.apache.commons.codec.digest.MurmurHash2

-     public final class MurmurHash2
      extends Object

  MurmurHash2 yields a 32-bit or 64-bit value. MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup. The name comes from two basic operations, multiply (MU) and rotate (R), used in its inner loop. Unlike cryptographic hash functions, it is not specifically designed to be difficult to reverse by an adversary, making it unsuitable for cryptographic purposes. This is a re-implementation of the original C code plus some additional features. Public domain.
  Since:
    1.13
  See Also:
    MurmurHash

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `hash32(byte[] data, int length)` Generates 32 bit hash from byte array with default seed value.
    `static int` | `hash32(byte[] data, int length, int seed)` Generates 32 bit hash from byte array of the given length and seed.
    `static int` | `hash32(String text)` Generates 32 bit hash from a string.
    `static int` | `hash32(String text, int from, int length)` Generates 32 bit hash from a substring.
    `static long` | `hash64(byte[] data, int length)` Generates 64 bit hash from byte array with default seed value.
    `static long` | `hash64(byte[] data, int length, int seed)` Generates 64 bit hash from byte array of the given length and seed.
    `static long` | `hash64(String text)` Generates 64 bit hash from a string.
    `static long` | `hash64(String text, int from, int length)` Generates 64 bit hash from a substring.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### hash32

          public static int hash32(byte[] data,
                                   int length,
                                   int seed)

      Generates 32 bit hash from byte array of the given length and seed.
      Parameters:
        `data` - byte array to hash
        `length` - length of the array to hash
        `seed` - initial seed value
      Returns:
        32 bit hash of the given array

    - #### hash32

          public static int hash32(byte[] data,
                                   int length)

      Generates 32 bit hash from byte array with default seed value.
      Parameters:
        `data` - byte array to hash
        `length` - length of the array to hash
      Returns:
        32 bit hash of the given array

    - #### hash32

          public static int hash32(String text)

      Generates 32 bit hash from a string.
      Parameters:
        `text` - string to hash
      Returns:
        32 bit hash of the given string

    - #### hash32

          public static int hash32(String text,
                                   int from,
                                   int length)

      Generates 32 bit hash from a substring.
      Parameters:
        `text` - string to hash
        `from` - starting index
        `length` - length of the substring to hash
      Returns:
        32 bit hash of the given string

    - #### hash64

          public static long hash64(byte[] data,
                                    int length,
                                    int seed)

      Generates 64 bit hash from byte array of the given length and seed.
      Parameters:
        `data` - byte array to hash
        `length` - length of the array to hash
        `seed` - initial seed value
      Returns:
        64 bit hash of the given array

    - #### hash64

          public static long hash64(byte[] data,
                                    int length)

      Generates 64 bit hash from byte array with default seed value.
      Parameters:
        `data` - byte array to hash
        `length` - length of the array to hash
      Returns:
        64 bit hash of the given string

    - #### hash64

          public static long hash64(String text)

      Generates 64 bit hash from a string.
      Parameters:
        `text` - string to hash
      Returns:
        64 bit hash of the given string

    - #### hash64

          public static long hash64(String text,
                                    int from,
                                    int length)

      Generates 64 bit hash from a substring.
      Parameters:
        `text` - string to hash
        `from` - starting index
        `length` - length of the substring to hash
      Returns:
        64 bit hash of the given array

Copyright © 2002–2019 The Apache Software Foundation. All rights reserved.