Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Functions used to convert 64bit Steam ID to 32bit and the other way around.
<?php
function convert_steamid_64bit_to_32bit($id)
{
$result = substr($id, 3) - 61197960265728;
return (string) $result;
}
function convert_steamid_32bit_to_64bit($id)
{
$result = '765'.($id + 61197960265728);
return (string) $result;
}
$sixtyfour = '76561197992765754';
$thirtytwo = '32500026';
var_dump(convert_steamid_32bit_to_64bit($thirtytwo) === $sixtyfour); // bool(true)
var_dump(convert_steamid_64bit_to_32bit($sixtyfour) === $thirtytwo); // bool(true)
@AucT

This comment has been minimized.

Copy link

@AucT AucT commented Aug 2, 2013

wow this is awesome!!

@almirsarajcic

This comment has been minimized.

Copy link
Owner Author

@almirsarajcic almirsarajcic commented Aug 5, 2013

Thanks :)

@imvision

This comment has been minimized.

Copy link

@imvision imvision commented Sep 9, 2013

Thanks for this!

@nenad

This comment has been minimized.

Copy link

@nenad nenad commented Nov 5, 2013

Thanks! I needed this.

@29942016

This comment has been minimized.

Copy link

@29942016 29942016 commented Nov 30, 2013

wow so simple thanks, also how did you get the base number? like what was your source? just out of curiosity.

@rastating

This comment has been minimized.

Copy link

@rastating rastating commented May 23, 2014

Very useful! I'd also be interested to know what your source was, if you can remember.

@johanfalk

This comment has been minimized.

Copy link

@johanfalk johanfalk commented Aug 12, 2014

Awesome stuff +1

@Shigbeard

This comment has been minimized.

Copy link

@Shigbeard Shigbeard commented Oct 8, 2014

Doesnt work. It produces a false number converting 32 to 64.

@danfsd

This comment has been minimized.

Copy link

@danfsd danfsd commented Dec 5, 2014

I was testing this on Xampp for Windows and it didn't worked. I'm guessing that this have something to do with the unavailability of the 64-bit version of both Xampp and PHP for Windows. I'll test this on a Linux to see if the result is right.
Thanks in advance!

@almirsarajcic

This comment has been minimized.

Copy link
Owner Author

@almirsarajcic almirsarajcic commented Aug 5, 2016

@danfsd, this was intended for 32-bit PHP environments and that unavailability was the reason I created this.

@rumblefrog

This comment has been minimized.

Copy link

@rumblefrog rumblefrog commented Apr 1, 2017

Would you happen to know a direct relation for Group ID as well?

@aspdotnet-sekhar

This comment has been minimized.

Copy link

@aspdotnet-sekhar aspdotnet-sekhar commented Feb 16, 2020

Thanks! you saved much time for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment