wangyi-fudan/wyhash logo

wangyi-fudan/wyhash

Free

The FASTEST QUALITY hash function, random number generators (PRNG) and hash map.

FreeFree tier
Type
Open Source

About wangyi-fudan/wyhash

wyhash is a non-cryptographic hash function and pseudorandom number generator (wyrand) known for its speed and quality. It has passed major statistical tests: SMHasher for hashing, and BigCrush and PractRand for PRNG. wyhash is portable across 64-bit and 32-bit systems and big/little endian architectures, efficient especially for short keys, and uses a dynamic secret to mitigate hash collision attacks. It has been adopted as the default hashing algorithm in programming languages including Zig, V, Nim, and Go (since 1.17), and is deployed by Microsoft in Windows Terminal. However, wyhash has known limitations: it is not 64-bit collision resistant (about 62 bits) and wyrand fails PractRand on very long datasets (32TB). Multiple language bindings exist for C#, C++, Go, Java, Rust, Swift, and more.

Key Features

Passed SMHasher (hash) and BigCrush/PractRand (PRNG) tests
Portable across 64-bit, 32-bit, big/little endian systems
Efficient on 64-bit machines, especially for short keys
Simplest code size among similar functions
Salted with dynamic secret to avoid collision attacks
Default hashing algorithm in Zig, V, Nim, and Go (since 1.17)
Deployed by Microsoft on Windows Terminal
Multiple language bindings available (C#, C++, Go, Java, Rust, Swift, etc.)

Pros & Cons

Pros
  • Passes stringent quality tests (SMHasher, BigCrush, PractRand)
  • Highly portable across CPU architectures and endianness
  • Very fast, especially for short keys
  • Simple and easy to integrate with minimal code
  • Salted to prevent hash flooding attacks
  • Widely adopted by major languages and organizations
Cons
  • Not 64-bit collision resistant (approximately 62-bit collision resistance)
  • Wyrand fails PractRand on very long datasets (32TB)
  • Intended for non-cryptographic use only; not suitable for security-critical hashing
  • May have undiscovered flaws (authors acknowledge limitations)

Best For

Non-cryptographic hashing for hash maps and data structuresPseudorandom number generation with wyrandGeneral-purpose fast hashing in performance-critical applicationsDefault hasher in programming language runtimes (Zig, V, Nim, Go)Integration in software terminals and tools (Windows Terminal)

FAQ

What tests does wyhash pass?
Wyhash passes SMHasher for hash quality. Wyrand passes BigCrush and PractRand (tested up to 512GB).
What are the limitations of wyhash?
Wyhash is not 64-bit collision resistant (about 62 bits). Wyrand fails PractRand on very long datasets (32TB). It is not suitable for cryptographic purposes.
Which programming languages use wyhash as default?
Zig, V, Nim, and Go (since version 1.17) use wyhash as their default hashing algorithm.
Has wyhash been used in production?
Yes, Microsoft has deployed wyhash on Windows Terminal.
Is wyhash portable?
Yes, wyhash is portable across 64-bit and 32-bit systems and supports both big and little endian architectures.