This commit is contained in:
Christoph J. Scherr 2023-04-25 12:21:28 +02:00
parent 4690fe53da
commit 772b8faced
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 10 additions and 2 deletions

View File

@ -26,14 +26,22 @@ VALUE_SIZE = 4
The rotations are tested agains a c implementation and are still garbage. FIXME The rotations are tested agains a c implementation and are still garbage. FIXME
""" """
def rotl(value: int, count: int) -> int: def rotl(value: int, count: int) -> int:
# FIXME
mask: int = CHAR_BIT * VALUE_SIZE - 1; mask: int = CHAR_BIT * VALUE_SIZE - 1;
print("mask length: %d" % mask.bit_length())
count = count & mask count = count & mask
return (value << count) | (value >> (-count & mask)); result = (value << count) | (value >> (-count & mask));
assert result.bit_length() <= 32, "python made the numbers too big: %d bit" % result.bit_length()
return result
def rotr(value: int, count: int) -> int: def rotr(value: int, count: int) -> int:
# FIXME
mask: int = CHAR_BIT * VALUE_SIZE - 1; mask: int = CHAR_BIT * VALUE_SIZE - 1;
print("mask length: %d" % mask.bit_length())
count = count & mask count = count & mask
return (value >> count) | (value << (-count & mask)); result = (value >> count) | (value << (-count & mask));
assert result.bit_length() <= 32, "python made the numbers too big: %d bit" % result.bit_length()
return result
""" """
Now for the actual implementation of authur1 Now for the actual implementation of authur1