PJW hash function
PJW hash function is an encyclopedia record, sourced from en.wikipedia.org, last updated 2024-10-25, source revision https://en.wikipedia.org/w/index.php?oldid=1253333688. PJW hash function is a non-cryptographic hash function created by Peter J. Weinberger of AT&T Bell Labs. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
PJW hash function is a non-cryptographic hash function created by Peter J. Weinberger of AT&T Bell Labs. ==Other versions== A variant of PJW hash had been used to create ElfHash or Elf64 hash that is used in Unix object files with ELF format. Allen Holub has created a portable version of PJW hash algorithm that had a bug and ended up in several textbooks, as the author of one of these textbooks later admitted. ==Algorithm== PJW hash algorithm involves shifting the previous hash and adding the current byte followed by moving the high bits: algorithm PJW_hash(s) is uint h := 0 bits := uint size in bits for i := 1 to |S| do h := h > bits * 3/4) h := h & ~high return h ==Implementation== Below is the algorithm implementation used in Unix ELF format: unsigned long ElfHash(const unsigned char *s) { unsigned long h = 0, high; while (*s) { h = (h > 24; h &= ~high; } return h; } This C code incorrectly assumes that long is a 32-bit data type. When long is wider than 32 bits, as it is on many 64-bit systems, the code contains a bug. ==References==
References
- ^ Binstock, Andrew (1996). "Hashing Rehashed" . Dr. Dobb's . Wikipedia revision 1253333688, retrieved 2026-11-20 · 1795129200.0
- ^ "Hash Functions" . www.cs.hmc.edu . Retrieved 2015-06-10 . Wikipedia revision 1253333688, retrieved 2026-11-20 · 1433890800.0
- ^ CORPORATE UNIX Press (1993). System V application binary interface . ISBN 0-13-100439-5 . Wikipedia revision 1253333688, retrieved 2026-11-20 · 1795129200.0
- ^ "ELF hash function may overflow" . 12 April 2023 . Retrieved 2023-04-14 . Wikipedia revision 1253333688, retrieved 2026-11-20 · 1681426800.0
Cite this
"PJW hash function". 1729853240. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1253333688 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy