From 596010bb8e6f3e00de55ee3885c344a3ba64aba8 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Tue, 25 Apr 2023 19:02:51 +0200 Subject: [PATCH] hash works --- src-py/authur1.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src-py/authur1.py b/src-py/authur1.py index 30cc34d..d6f99bf 100755 --- a/src-py/authur1.py +++ b/src-py/authur1.py @@ -9,6 +9,7 @@ Since this (auth) hash did not have a name before, I gave it the name 'authur1' @source: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/authur1.py """ import argparse +from sre_constants import IN_UNI_IGNORE # FIXME make proper pyi Implementation for the rust part from plexcryptool import binary @@ -39,6 +40,8 @@ def inner_authur1(input: int) -> int: return output def authur1(input: bytearray, verbose: bool = False) -> bytearray: + if verbose: + print("input: %s" % input) internal_buffer: bytearray = bytearray() accumulator: bytearray = DEFINED_INITIAL for in_byte in input: @@ -79,9 +82,11 @@ def authur1(input: bytearray, verbose: bool = False) -> bytearray: if verbose: print("returning state: %s" % accumulator.hex()) # now Q the accumulator and return - accuint = int.from_bytes(accumulator) - accuint = inner_authur1(accuint) - accumulator = bytearray(accuint.to_bytes(4)) + # if input = "" this step breaks things, just remove it. + if len(input) != 0: + accuint = int.from_bytes(accumulator) + accuint = inner_authur1(accuint) + accumulator = bytearray(accuint.to_bytes(4)) return accumulator def test(): @@ -95,7 +100,7 @@ def test(): print("Q aka inner_authur1 passed the test") - ha = authur1(bytearray(0)) + ha = authur1(bytearray(0), True) hb = authur1(bytearray(b'A')) hc = authur1(bytearray(b'AB')) hd = authur1(bytearray(b'ABC'))