diff --git a/src/pyotp/contrib/steam.py b/src/pyotp/contrib/steam.py index 1cd2bdd..35c6cc6 100644 --- a/src/pyotp/contrib/steam.py +++ b/src/pyotp/contrib/steam.py @@ -29,16 +29,12 @@ def generate_otp(self, input: int) -> str: :param input: the HMAC counter value to use as the OTP input. Usually either the counter, or the computed integer based on the Unix timestamp """ - str_code = super().generate_otp(input) - int_code = int(str_code) - - steam_code = "" + int_code = int(super().generate_otp(input)) total_chars = len(STEAM_CHARS) + digits = [] for _ in range(STEAM_DEFAULT_DIGITS): - pos = int_code % total_chars - char = STEAM_CHARS[int(pos)] - steam_code += char + digits.append(STEAM_CHARS[int_code % total_chars]) int_code //= total_chars - return steam_code + return "".join(digits)