Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hashes/adler32.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def adler32(plain_text: str) -> int:
"""
Function implements adler-32 hash.
Iterates and evaluates a new value for each character
Iterates over the UTF-8 bytes of the input text.

>>> adler32('Algorithms')
363791387
Expand All @@ -24,7 +24,7 @@ def adler32(plain_text: str) -> int:
"""
a = 1
b = 0
for plain_chr in plain_text:
a = (a + ord(plain_chr)) % MOD_ADLER
for plain_byte in plain_text.encode("utf-8"):
a = (a + plain_byte) % MOD_ADLER
b = (b + a) % MOD_ADLER
return (b << 16) | a