- dechex: documentation ( source)
- str_pad: documentation ( source)
- ord: documentation ( source)
<?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);
}
echo jenkins_hash("3v4l.org is an online shell that allows you to evaluate (hence 3v4l) your code on my server.");