SteamTotpNet 1.0.0
dotnet add package SteamTotpNet --version 1.0.0
NuGet\Install-Package SteamTotpNet -Version 1.0.0
<PackageReference Include="SteamTotpNet" Version="1.0.0" />
<PackageVersion Include="SteamTotpNet" Version="1.0.0" />
<PackageReference Include="SteamTotpNet" />
paket add SteamTotpNet --version 1.0.0
#r "nuget: SteamTotpNet, 1.0.0"
#:package SteamTotpNet@1.0.0
#addin nuget:?package=SteamTotpNet&version=1.0.0
#tool nuget:?package=SteamTotpNet&version=1.0.0
SteamTotp
A .NET library for generating Steam-style TOTP authentication codes. Supports Steam Guard codes, mobile confirmation keys, device ID generation, and server time synchronization.
Installation
dotnet add package SteamTotp
Quick Start
using SteamTotp;
var service = new SteamTotpService();
// Generate a Steam Guard code from a hex secret
var code = service.GenerateAuthCodeHex("0123456789ABCDEF0123456789ABCDEF01234567");
Console.WriteLine(code); // e.g., "2W3R4"
API Reference
SteamTotpService
Main service for TOTP operations.
// Create with default dependencies
var service = new SteamTotpService();
// Create with custom dependencies (for testing)
var service = new SteamTotpService(customTimeProvider, customSecretDecoder);
Generate Authentication Code
// From hex secret
string code = service.GenerateAuthCodeHex("0123456789ABCDEF0123456789ABCDEF01234567");
// From base64 secret
string code = service.GenerateAuthCode("SGVsbG8gV29ybGQ=");
// From raw bytes
string code = service.GenerateAuthCode(secretBytes);
// With time offset (seconds ahead/behind Steam server)
string code = service.GenerateAuthCodeHex("0123456789ABCDEF...", offset: 10);
The offset parameter adjusts for clock drift between your server and Steam's servers. Use TimeOffsetService to calculate the correct offset.
Generate Confirmation Key
Generates keys needed for mobile trade confirmations.
// With tag: "conf" (confirm), "allow" (approve), "cancel" (reject), "details" (details)
string key = service.GenerateConfirmationKeyHex("FEDCBA9876543210...", timestamp, "conf");
// From base64 identity secret
string key = service.GenerateConfirmationKey(base64IdentitySecret, timestamp, "conf");
Get Current Time
long time = service.Time();
long timeWithOffset = service.Time(offset: 10);
TimeOffsetService
Synchronize with Steam's server time to ensure generated codes are valid.
var offsetService = new TimeOffsetService();
var result = await offsetService.GetTimeOffsetAsync();
Console.WriteLine($"Offset: {result.Offset}s");
Console.WriteLine($"Latency: {result.LatencyMs}ms");
Use the offset when generating codes:
var offsetService = new TimeOffsetService();
var result = await offsetService.GetTimeOffsetAsync();
var code = service.GenerateAuthCodeHex(secret, offset: (int)result.Offset);
DeviceIdGenerator
Generate standardized Android device IDs from SteamIDs.
var generator = new DeviceIdGenerator();
string deviceId = generator.GetDeviceId("STEAM_1:1:12345678");
// android:f1776fe6-a7ae-c9c3-e8f8-036c7edc1d31
// With custom salt
string deviceId = generator.GetDeviceId("STEAM_1:1:12345678", "my-salt");
SecretDecoder
Decode hex and base64 encoded secrets.
var decoder = new SecretDecoder();
byte[] fromHex = decoder.DecodeHex("0123456789ABCDEF");
byte[] fromBase64 = decoder.DecodeBase64("SGVsbG8gV29ybGQ=");
Architecture
The library follows SOLID principles with dependency injection support:
| Interface | Default Implementation | Purpose |
|---|---|---|
ITimeProvider |
TimeProvider |
Time abstraction (DateTimeOffset.UtcNow) |
ISecretDecoder |
SecretDecoder |
Hex/Base64 decoding |
IDeviceIdGenerator |
DeviceIdGenerator |
Device ID generation |
ITimeOffsetService |
TimeOffsetService |
Server time sync |
Testing
dotnet test
Requirements
- .NET Standard 2.0 compatible runtime
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Memory (>= 4.5.5)
- System.Text.Json (>= 4.7.2)
- System.Threading.Tasks.Extensions (>= 4.5.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 136 | 5/23/2026 |
Initial release with TOTP code generation, confirmation keys, device ID generation, and time offset sync.