Last active
September 4, 2024 06:25
-
-
Save kasuganosoras/7944d635746a31eb8dda5c5c28ba3580 to your computer and use it in GitHub Desktop.
PHP Get GTA5 Hash key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetGtaHashKey($name, $format = false) | |
{ | |
$num = 0; | |
$byte = unpack('C*', utf8_encode($name)); | |
for ($i = 1; $i <= count($byte); $i++) { | |
$num += $byte[$i]; | |
$num += $num << 10; | |
$num &= 0xFFFFFFFF; | |
$num ^= $num >> 6; | |
} | |
$num += $num << 3; | |
$num &= 0xFFFFFFFF; | |
$num ^= $num >> 11; | |
$result = ($num + ($num << 15)); | |
$result &= 0xFFFFFFFF; | |
if($result > 2147483647) { | |
$result -= 4294967296; | |
} | |
return $format ? sprintf("0x%08X", $result) : $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment