Skip to content

Instantly share code, notes, and snippets.

@WardPearce
Last active September 19, 2019 22:53
Show Gist options
  • Save WardPearce/e8cb8d9db673c28616566698b67d1170 to your computer and use it in GitHub Desktop.
Save WardPearce/e8cb8d9db673c28616566698b67d1170 to your computer and use it in GitHub Desktop.
Easily converts SteamID64 or 32 into both 32 & 64.
def steamid_convert(given_id):
steam64id = 76561197960265728
if "STEAM_0" in given_id or "STEAM_1" in given_id:
id_split = given_id.split(":")
steam64id += int(id_split[2]) * 2
if id_split[1] == "1":
steam64id += 1
return_data = [given_id.replace("STEAM_0", "STEAM_1"), steam64id]
elif given_id.isdigit() and len(given_id) == 17:
y = int(given_id) - steam64id
x = y % 2
return_data = ["STEAM_1:{}:{}".format(x, (y - x) // 2), given_id]
else:
return_data = False
return return_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment