IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.1.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

hash

def hash[T: Hashable, //, HasherType: Hasher = AHasher[SIMD[.uint64, 4](0)]](hashable: T) -> UInt64

Hash a Hashable type using its underlying hash implementation.

Parameters:

  • ​T (Hashable): Any Hashable type.
  • ​HasherType (Hasher): Type of the hasher which should be used for hashing.

Args:

  • ​hashable (T): The input data to hash.

Returns:

UInt64: A 64-bit integer hash based on the underlying implementation.

def hash[HasherType: Hasher = AHasher[SIMD[.uint64, 4](0)]](bytes: Pointer[UInt8], n: Int) -> UInt64

Hash a sequence of bytes using the specified hasher.

Parameters:

  • ​HasherType (Hasher): Type of the hasher to use for hashing (default: AHasher).

Args:

  • ​bytes (Pointer[UInt8]): Pointer to the byte sequence to hash.
  • ​n (Int): The number of bytes to hash.

Returns:

UInt64: A 64-bit integer hash value.