/// <summary> /// Produces a token for a specific Steam ID. This token is signed by this server to prevent abuse. It can be checked later by any DeltaWebMap server. /// </summary> /// <returns></returns> public string CreateSteamIdTokenString(string steamId) { //Create a buffer for the message byte[] buffer = new byte[16 + 1 + Encoding.ASCII.GetByteCount(steamId)]; //Write buffer contents steamTokenKey.CopyTo(buffer, 0); buffer[16] = 0x01; Encoding.ASCII.GetBytes(steamId, 0, steamId.Length, buffer, 17); //Create HMAC and write it byte[] hash = new HMACMD5(steamTokenKey).ComputeHash(buffer); if (hash.Length != 16) { throw new Exception("Invalid hash length."); } hash.CopyTo(buffer, 0); //Return the BASE64 version of this return(Convert.ToBase64String(buffer)); }