java.lang.Object
net.i2p.util.SipHash

public abstract class SipHashextends Object
Wrapper around SipHashInline with constant per-JVM keys.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long
    First key word, random per JVM so the hash is not predictable
    private static final long
    Second key word, random per JVM
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for subclasses that hash with their own key rather than the per-JVM key.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    static long
    digest(byte[] data)
    Hash a whole array.
    static long
    digest(byte[] data, int off, int len)
    Hash a region of an array.
    static int
    hashCode(byte[] data)
    Secure replacement for DataHelper.hashCode(byte[]); caching recommended.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • K0

      private static final long K0
      First key word, random per JVM so the hash is not predictable
    • K1

      private static final long K1
      Second key word, random per JVM
  • Constructor Details

    • SipHash

      public SipHash()
      Constructor for subclasses that hash with their own key rather than the per-JVM key.
  • Method Details

    • digest

      public static long digest(byte[] data)
      Hash a whole array.
      Parameters:
      data - non-null
      Returns:
      the 64-bit SipHash-2-4 digest of the array under this JVM's random keys
    • digest

      public static long digest(byte[] data, int off, int len)
      Hash a region of an array.
      Parameters:
      data - non-null
      off - the index in data at which the hashed region begins
      len - the number of bytes to hash, counting from off
      Returns:
      the 64-bit SipHash-2-4 digest of that region under this JVM's random keys
    • hashCode

      public static int hashCode(byte[] data)
      Secure replacement for DataHelper.hashCode(byte[]); caching recommended.
      Parameters:
      data - may be null
      Returns:
      whether h code is present