Bob Jenkins' One-At-A-Time hashing algorithm is simply known as jenkins_hash() providing 8 bytes long hash value.
<?php // Bob Jenkins' One-At-A-Time hashing algorithm. function jenkins_hash($key) { $key = (string)$key; $len = strlen($key); for($hash = $i = 0; $i < $len; ++$i) { $hash += ord($key[$i]); $hash += ($hash << 10); $hash ^= ($hash >> 6); } $hash += ($hash << 3); $hash ^= ($hash >> 11); $hash += ($hash << 15); return str_pad(dechex($hash),16,0,STR_PAD_LEFT); } ?>
For better security, I prefer to add salt as following:
<?php // Bob Jenkins' One-At-A-Time hashing algorithm with Salt function jenkins_hash($key, $salt=337) { $key = (string)$key; $len = strlen($key); for($hash = $salt, $i = 0; $i < $len; ++$i) { $hash += ord($key[$i]); $hash += ($hash << 10); $hash ^= ($hash >> 6); } $hash += ($hash << 3); $hash ^= ($hash >> 11); $hash += ($hash << 15); return str_pad(dechex($hash),16,0,STR_PAD_LEFT); } ?>
If you want more shorter hash value, please refer 32bits simple hash function in PHP.