hashes/adler32.py: checksum diverges from the Adler-32 spec for any non-ASCII input (sums Unicode code points instead of bytes)
Los mantenedores suelen responder en 1 día
@SwetaKumari7 ya está trabajando en esto.
Desde el 24/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
Línea de trabajo
The bug is in hashes/adler32.py: adler32() sums ord() per Unicode character instead of per byte. Fix by encoding the input to UTF-8 first (or accepting bytes), mirroring how the sibling hashes/crc32.py already works against zlib.crc32. Verify with the issue's reproduction snippet comparing against zlib.adler32(text.encode()) for non-ASCII strings like '€100' and '日本語テスト', and update the doctests which only cover ASCII. Note an open pull request is already linked, so check whether work is under way before starting.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Repository commit
6e03a48579ca212a08b36be00378f887dc41a003
Python version (python --version)
Python 3.13.5
Dependencies version (pip freeze)
None needed — hashes/adler32.py only uses the standard library.
Expected behavior
Adler-32 is defined over a byte stream, so adler32(text) should produce the same value as the reference implementation on the text's UTF-8 bytes (zlib.adler32(text.encode())), for any input text. The sibling module hashes/crc32.py does exactly this (it takes bytes and matches zlib.crc32 for every input).
Actual behavior
adler32 iterates Unicode code points and sums ord(char), so it only matches the real Adler-32 for pure-ASCII text. Every non-ASCII character silently produces a checksum that no standard implementation would produce:
>>> from hashes.adler32 import adler32
>>> import zlib
>>> adler32('Algorithms')
363791387
>>> zlib.adler32('Algorithms'.encode())
363791387
>>> adler32('€100')
2211914046
>>> zlib.adler32('€100'.encode())
196018850
>>> adler32('日本語テスト')
3064850950
>>> zlib.adler32('日本語テスト'.encode())
2053180537
For a checksum/integrity algorithm, producing values that disagree with every other Adler-32 implementation (zlib, Python's zlib.adler32, etc.) for non-ASCII input makes the results unusable for verification.
Steps to reproduce
python - <<'EOF'
from hashes.adler32 import adler32
import zlib
for s in ['Algorithms', 'héllo', '€100', '日本語テスト']:
print(s, adler32(s), zlib.adler32(s.encode()), adler32(s) == zlib.adler32(s.encode()))
EOF
Output: only 'Algorithms' matches; the other three lines end with False.
Suspected cause
hashes/adler32.py (adler32(plain_text: str)) uses a = (a + ord(plain_chr)) % MOD_ADLER per character. Encoding the input to UTF-8 first (like crc32.py already requires bytes) would keep it on-spec for all inputs; the doctests only cover ASCII strings, so this never shows up in the test run.
- Lenguaje dominante
- Python
- Estrellas
- 225k
- Forks
- 51.2k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 40
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TheAlgorithms/Python
-
ciphers/base32.py and ciphers/base85.py encode Unicode code points instead of bytes: output diverges from the spec for non-ASCII, round-trips corrupt chars >= U+0400, arbitrary bytes crashPosiblemente ocupada @Nate-br la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
TheAlgorithms/Python#15636 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
ciphers/des_ecb.py: encrypt/decrypt silently corrupts any character above U+00FF (round-trip fails)Posiblemente ocupada @mohammedanasnakhuda la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
TheAlgorithms/Python#15634 ·
Los mantenedores suelen responder en 1 día
-
other/password.py: alternative_password_generator ignores the requested length when the required characters exceed itPosiblemente ocupada @raaj-2222 la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
TheAlgorithms/Python#15633 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
ciphers/base58.py is a copy of base64_cipher.py — no Base58 implementation exists in the filePosiblemente ocupada @SakshiYeole la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
TheAlgorithms/Python#15637 ·
Los mantenedores suelen responder en 1 día
-
Optimize Node.has_loop to use constant auxiliary space instead of O(N) spacePosiblemente ocupada @mohitjoshi-hey la tomó hace 13 días. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 15/100
TheAlgorithms/Python#15576 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de TheAlgorithms/Python
Issues similares
-
backlog
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
EchoTools/nevr-runtime#1108 ·
Los mantenedores suelen responder en 1 día
-
parse names a key after a top-level multi() threshold Bitcoin Core v31.1 refuses as not validAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
btclib-org/btclib-wallet#587 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Judgment-Pack/judgment-pack-spec#275 ·
Los mantenedores suelen responder en 1 día