3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function doHash($string) { if ($string == "") return ""; $passwordChars = "abcdefghijklmnopqrstuvwxyz_"; $hashChars = "0123456789ABCDEF"; $hashedString = ""; $hashArray = Array(32); for($i=0; $i<32; $i++) $hashArray[$i]=GetCharacterKey($string, $i); for ($i=0; $i<32; $i++) { if (strpos($passwordChars, substr($string, $i%strlen($string), 1)) == -1) $string= substr($string, 0, $i%strlen($string)) . "_" . substr($string, ($i%strlen($string))+1, (strlen($string)-($i%strlen($string)))-1); $hashArray[$i] += (floor(strpos($passwordChars, substr($string, $i%strlen($string), 1))/9)*16 + floor(strpos($passwordChars, substr($string, $i%strlen($string), 1))%9/3)*4 + floor(strpos($passwordChars, substr($string, $i%strlen($string), 1))%3)); for ($j=0; $j<3; $j++){ if (($hashArray[$i]&(48>>($j*2))) == (32>>($j*2)) && (GetCharacterKey($string, $i)&(1<<$j))==(1<<$j)) { $hashArray[i]=($hashArray[$i]&(255-(48>>($j*2)))) + (48>>($j*2)); } } for ($j=0; $j<2; $j++) { $hashArray[$i] += floor($hashArray[($i+$j)%32]/1234)*pow(4,$j+3); } $doubleByteHashNumber = 0; for ($j=0; $j<16; $j++){ $doubleByteHashNumber += (($hashArray[$i]&pow(2,($j*2)+($i%2)))>>($j+($i%2))); } $hashArray[$i] = $doubleByteHashNumber; echo ($hashArray[$i]&65280)>>8; echo " " .($hashArray[$i]&255) . "\n"; $hashedString .= substr($hashChars, floor((($hashArray[$i]&65280)>>8)/16), 1); $hashedString .= substr($hashChars, floor((($hashArray[$i]&65280)>>8)%16), 1); $hashedString .= substr($hashChars, floor(($hashArray[$i]&255)/16), 1); $hashedString .= substr($hashChars, floor(($hashArray[$i]&255)%16), 1); } return $hashedString; } function GetCharacterKey($string, $character) { $passwordChars = "abcdefghijklmnopqrstuvwxyz_"; $key = strpos($passwordChars, $string[$character%strlen($string)]); for($i=0; $i<10+strlen($string)+($character*3); $i++) { $key = ($key<<1); $key %= 2147483648; $key += strpos($passwordChars, $string[$i%strlen($string)]); $key = floor(sin($key)*1000000); } if ($key < 0) { return -(2147483648 - ($key & 2147483584)); } else { return ($key & 2147483584); } } echo doHash("ab"); ?>
based on slPL7
Output for 5.5.0 - 7.3.0beta1
254 64 2 32 2 200 2 128 5 176 2 104 2 232 252 16 1 216 253 64 0 104 252 160 254 208 2 160 3 48 2 192 252 56 255 224 254 216 0 32 1 152 3 72 252 96 1 152 3 160 254 144 2 248 255 216 253 208 252 16 0 88 3 56 FE40022002C8028005B0026802E8FC1001D8FD400068FCA0FED002A0033002C0FC38FFE0FED8002001980348FC60019803A0FE9002F8FFD8FDD0FC1000580338