Search code examples
c#steam

How to get the normal Steam ID from the Steam ID 64 using c#


Steams Open ID only returns the Steam ID 64:

For example: 76561198025336843

How can I convert it to the real Steam ID?

For example: STEAM_0:1:32535557

Is there a way to obtain the Information?


Solution

  • That is absolutly possible. The real Steam ID can be calculated from the 64-bit integer (long).

    Basicly we can extract the following two informations using some calculations:

    • The authentification Server
    • The authentification Id

    With this informations, we can concatenate the Steam ID. Here are two Utility methods for it:

    public static string GetSteamId(string steamId64)
    {
        return GetSteamId(long.Parse(steamId64));
    }
    
    public static string GetSteamId(long steamId64)
    {
        var authserver = (steamId64 - 76561197960265728) & 1;
        var authid = (steamId64 - 76561197960265728 - authserver) / 2;
        return $"STEAM_0:{authserver}:{authid}";
    }
    

    Usage:

    var result = GetSteamId("76561198025336843");
    //result: STEAM_0:1:32535557