Skip to content

Instantly share code, notes, and snippets.

@kasuganosoras
Last active September 4, 2024 06:25
Show Gist options
  • Save kasuganosoras/7944d635746a31eb8dda5c5c28ba3580 to your computer and use it in GitHub Desktop.
Save kasuganosoras/7944d635746a31eb8dda5c5c28ba3580 to your computer and use it in GitHub Desktop.
PHP Get GTA5 Hash key
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