Skip to content

Instantly share code, notes, and snippets.

@ericek111
Last active October 20, 2018 22:31
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 ericek111/ec1d45d7ffb2f25571961a5084a8dea9 to your computer and use it in GitHub Desktop.
Save ericek111/ec1d45d7ffb2f25571961a5084a8dea9 to your computer and use it in GitHub Desktop.
Perl SteamID64 parser
#!/usr/bin/perl
use bigint;
die "Usage: $0 (steamID64)\n" if @ARGV < 1;
# https://developer.valvesoftware.com/wiki/SteamID
my $sid = @ARGV[0];
my $up = ($sid >> 32) & (2**32 - 1);
my $down = $sid & (2**32 - 1);
printf("Y: %d\n", $down & 1);
$down >>= 1;
printf("acc. num: %d\n", $down);
printf("instance: %d\n", $up & (2**20 - 1));
$up >>= 20;
printf("type: %d\n", $up & (2**4 - 1));
$up >>= 4;
printf("universe: %d / %d\n", $up, $up & (2**7 - 1));
#handle non-Steam IDs:
if (($up >> 7) > 0) {
# this would've probably been a better idea, but HLstatsX displays SIDs wrong
# printf("> STEAM_%d:VALVE_%d:%d:%d\n", $up, $up >> 7, $up & (2**7 - 1), $down);
printf("> STEAM_0:VALVE_0:%d:%d\n", $up & (2**7 - 1), $down);
} else {
printf("> STEAM_%d:%d:%d\n", $up, $sid & 1, $down);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment