From 923d8f22b0dffbdeb7e58532bdd0bb3864330f58 Mon Sep 17 00:00:00 2001 From: Rafael Moraes <50295204+glomatico@users.noreply.github.com> Date: Sun, 8 Feb 2026 13:31:02 -0300 Subject: [PATCH] Specify big-endian counter bytes --- votify/totp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/votify/totp.py b/votify/totp.py index 5c070b8..be071d7 100644 --- a/votify/totp.py +++ b/votify/totp.py @@ -14,13 +14,13 @@ class TOTP: @staticmethod def derive(ciphertext: Collection[int]) -> bytes: - return ''.join( + return "".join( str(byte ^ ((i % 33) + 9)) for i, byte in enumerate(ciphertext) - ).encode('ascii') + ).encode("ascii") def generate(self, timestamp: int) -> str: counter = int(timestamp) // 1000 // self.PERIOD - counter_bytes = counter.to_bytes(8) + counter_bytes = counter.to_bytes(8, "big") h = hmac.new(self.secret, counter_bytes, hashlib.sha1) hmac_result = h.digest()