Advertisement
Guest User

C# Steam ID / Community ID Conversion

a guest
Apr 24th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Steam Community & ID Converts Visa Versa...
  3.  
  4.     Algorithms from:
  5.  
  6.         * http://www.martinpace.com/downloads/SteamIDtoCommunityID.pdf
  7.         * http://stackoverflow.com/questions/7074978/conversion-to-64-bit-int
  8.    
  9.     ---|> Twitter: @Harrymilnes
  10. */
  11.  
  12.  
  13. public static string Id2SteamIdConverter(long param) // STEAM_0:0:41832667 TO 76561198043931062
  14. {
  15.         string steamIdentifier;
  16.         if (param % 2 == 0) { // Use Modulus to see if the param is even.
  17.             steamIdentifier = "STEAM_0:0:"; // It's gonna be even so we use this string
  18.         } else {
  19.             steamIdentifier = "STEAM_0:1:"; // It's gonna be odd so we use this string
  20.         }
  21.         var identifierSubtract = param - 76561197960265728; // We subract a base number from the param
  22.         var identifierTotal = identifierSubtract / 2; // Half the total
  23.         return steamIdentifier + identifierTotal; // YEAHHH BOII!
  24. }
  25.  
  26. public static long SteamId2IdConverter(string param) // 76561198043931062 TO STEAM_0:0:41832667
  27. {
  28.     var splitInfo = param.Split(':'); //Do da splitz.
  29.         var identifierMultiply = Int64.Parse(splitInfo[2]) * 2; // Multiply the unique number by 2 STEAM_0:0: [ 41832667 ] < DAT BIT
  30.         var identifierTotal = identifierMultiply + 76561197960265728;
  31.         identifierTotal += Int64.Parse(splitInfo[1]);  // Add the odd / even identifier :1: / :0:
  32.         return identifierTotal; // Hoorah.
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement