SipHasher

public struct SipHasher

An implementation of the SipHash-2-4 hashing algorithm, suitable for use in projects outside the Swift standard library. (The Swift stdlib already includes SipHash; unfortunately its API is not public.)

SipHash was invented by Jean-Philippe Aumasson and Daniel J. Bernstein.

  • Initialize a new instance with the default key, generated randomly the first time this initializer is called.

    Declaration

    Swift

    public init()
  • Initialize a new instance with the specified key.

    Parameter

    Parameter k0: The low 64 bits of the secret key.

    Parameter

    Parameter k1: The high 64 bits of the secret key.

    Declaration

    Swift

    public init(k0: UInt64, k1: UInt64)

    Parameters

    k0

    The low 64 bits of the secret key.

    k1

    The high 64 bits of the secret key.

  • Add all bytes in buffer to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ buffer: UnsafeRawBufferPointer)
  • Finalize this hash and return the hash value.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func finalize() -> Int
  • Add hashing components in value to this hash. This method simply calls value.addHashes.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append<H: SipHashable>(_ value: H)
  • Add the hash value of value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append<H: Hashable>(_ value: H)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Bool)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Int)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: UInt)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Int64)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: UInt64)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Int32)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: UInt32)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Int16)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: UInt16)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Int8)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: UInt8)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Float)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Double)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: Float80)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append(_ value: CGFloat)
  • Add value to this hash.

    Requires

    finalize() hasn’t been called on this instance yet.

    Declaration

    Swift

    public mutating func append<Value: Hashable>(_ value: Value?)