- substr: documentation ( source)
- hash: documentation ( source)
- hexdec: documentation ( source)
<?php
$game_id = 47399;
$private_seed = "969e82ae0b4a3cfd6bf2afea5cf8bd26ddc6c11f3ae676f5655e779607b3778f";
$public_seed = "076c26818441622607ad1bffbf5f02a90eaadb020532bda9a9d60aedfb217528";
$hash = hash("sha256", $private_seed . '-' . $public_seed . '-' . $game_id);
$flip = hexdec(substr($hash, 0, 8)) % 2 + 1;
echo "Server seed hash: " . hash("sha256", $private_seed) . "\n";
echo "Result: " . ($flip == 1 ? 'RED' : 'BLACK');