Skip to content

Instantly share code, notes, and snippets.

@OfficialSubZero
Last active February 23, 2019 08:40
Show Gist options
  • Select an option

  • Save OfficialSubZero/1c21c4e14669bf464d1bacee51d01531 to your computer and use it in GitHub Desktop.

Select an option

Save OfficialSubZero/1c21c4e14669bf464d1bacee51d01531 to your computer and use it in GitHub Desktop.
Converts 64 bit SteamID's to 32 bit in PHP easily :D Enjoy!
<?php
function convertSteamID($steamid64) {
$authserver = bcsub($steamid64, '76561197960265728') & 1;
$authid = (bcsub($steamid64, '76561197960265728')-$authserver)/2;
return "STEAM_0:$authserver:$authid";
}
/*
Example using steam OpenID. https://github.com/SmItH197/SteamAuthentication:
$steamid = $_SESSION['steamid'];
echo convertSteamID($steamid);
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment