This commit is contained in:
Manchik
2026-05-19 18:28:43 +03:00
parent 48c16b8d3a
commit 68433b74c0
183 changed files with 18415 additions and 192 deletions
+4 -1
View File
@@ -11,7 +11,10 @@ def generate_2fa_code(shared_secret: str) -> str:
"""Generate a Steam Guard 2FA code from shared_secret."""
timestamp = int(time.time()) // 30
msg = struct.pack(">Q", timestamp)
key = base64.b64decode(shared_secret)
# Normalise: accept both standard (+/) and URL-safe (-_) base64, fix padding
normalised = shared_secret.strip().replace("-", "+").replace("_", "/")
normalised += "=" * (-len(normalised) % 4)
key = base64.b64decode(normalised)
auth = hmac.new(key, msg, hashlib.sha1).digest()
offset = auth[19] & 0xF