Returns an int for the upper (first) 64 bits of an md5 hash of a string

namespace HH;

function non_crypto_md5_upper(
  string $str,
): int;

The MD5 hash, usually presented as a hex value, is taken as big endian, and this int result is the signed counterpart to the unsigned upper 64 bits.

This function and the _lower version are generally only intended for legacy use cases in which an MD5 hash is used to compute a number of 64 bits or less. These functions are faster and prettier than calling unpack+substr+md5/raw or hexdec+substr+md5. Note that hexdec converts to floating point (information loss) for some 64-bit unsigned values.

The faster and quite effective xxhash64 is generally recommended for non-crypto hashing needs when no backward compatibility is needed.


  • string $str


  • int