minible icon indicating copy to clipboard operation
minible copied to clipboard

Steam TOTP

Open EugeneRymarev opened this issue 2 years ago • 4 comments

Missing feature

Steam TOTP

Justification

Why not? 😊

Workarounds

Using WinAuth or Steam Android App 👎

import base64
import binascii
import hashlib
import hmac
import sys
import time


CHARS = '23456789BCDFGHJKMNPQRTVWXY'


def generate_steam_totp(secret_key):
    byte_time = binascii.unhexlify('%016x' % int(time.time() // 30))
    digest = hmac.new(base64.b32decode(secret_key), byte_time, hashlib.sha1).digest()
    start = ord(digest[19:20]) & 0xF
    full_code = int(binascii.hexlify(digest[start:start + 4]), 16) & 0x7fffffff
    code = ''
    for _ in range(5):
        code += CHARS[int(full_code) % 26]
        full_code /= 26
    return code


def main():
    print(generate_steam_totp(sys.argv[1]))


if __name__ == '__main__':
    main()

EugeneRymarev avatar Dec 25 '22 14:12 EugeneRymarev