Skip to content
Advertisement

Convert SteamID64 to SteamID

I’m looking for a way that I can take a SteamID64 (76561198032122624) and convert it to a SteamID (STEAM_0:0:35928448) in PHP. I’ve searched this quite a bit and I’m unable to find how to do this. I’m almost sure it’s possible since sites like steamid.io are able to find it, but I don’t know how.

Advertisement

Answer

All the info you need is on Valve’s SteamID wiki page:

Legacy Format

Steam IDs follow a fairly simple format when represented textually: “STEAM_X:Y:Z”, where X, Y and Z are integers.

  • X represents the “Universe” the steam account belongs to. If ‘X’ is 0, then this is Universe 1 (Public).
  • Y is the lowest bit of the Account ID. Thus, Y is either 0 or 1.
  • Z is the highest 31 bits of the Account ID.

As a 64-bit integer

Given the components of a Steam ID, a Steam ID can be converted to it’s 64-bit integer form as follows:

((Universe << 56) | (Account Type << 52) | (Instance << 32) | Account ID)

My PHP is very rusty, but here’s some (untested) pseudocode that should do roughly what’s required:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement