Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norfair00/351823a86d0939dd1fa2dfe2a400d10f to your computer and use it in GitHub Desktop.
Save norfair00/351823a86d0939dd1fa2dfe2a400d10f to your computer and use it in GitHub Desktop.
The function used to convert 64bit Steam ID to 32bit and the other way around.
<?php
function convert_id($id)
{
if (strlen($id) === 17)
{
$converted = substr($id, 3) - 61197960265728;
}
else
{
$converted = '765'.($id + 61197960265728);
}
return (string) $converted;
}
$sixtyfour = '76561197992765754';
$thirtytwo = '32500026';
var_dump(convert_id($thirtytwo) === $sixtyfour); // bool(true)
var_dump(convert_id($sixtyfour) === $thirtytwo); // bool(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment