ciphers/des_ecb.py: encrypt/decrypt silently corrupts any character above U+00FF (round-trip fails)
Mantenedores costumam responder em até 1 dia
@mohammedanasnakhuda já está trabalhando nisso.
Desde 25/10/2026.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 88/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- python
- Domínio
- cryptography
Direção de pesquisa
Comece em ciphers/des_ecb.py em Operations.string_to_bitset (por volta da linha 151), onde format(ord(char), "08b") emite mais de 8 bits para code points acima de U+00FF e desloca todo o fluxo de bits para fora do limite de byte. Quem reportou sugere ou lançar um ValueError para entradas não Latin-1 ou codificar primeiro para bytes UTF-8; decida qual opção mantém encrypt/decrypt como um round trip válido. Reproduza com o one-liner python do issue, corrija o caminho de codificação e verifique os round trips para strings ASCII, Latin-1 e multibyte como "€100" e "日本語"; um pequeno test que verifique a igualdade do round trip marcaria isso como concluído.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Repository commit
6e03a48579ca212a08b36be00378f887dc41a003
Python version (python --version)
Python 3.13.5
Dependencies version (pip freeze)
None needed — ciphers/des_ecb.py only uses the standard library.
Expected behavior
Encrypting a text and decrypting the result with the same key should round-trip to the original text. Nothing in the module docstring restricts the input to ASCII.
Actual behavior
Any character with a code point above 0xFF silently corrupts the data: the decrypted text is not the original, and no error is raised.
>>> from ciphers.des_ecb import Des
>>> key = "0123456789abcdef"
>>> ct = Des.encrypt(key, "€100")
>>> Des.decrypt(key, ct)
'\x82°ÄÀÀ'
Same for CJK input:
>>> ct = Des.encrypt(key, "日本語")
>>> Des.decrypt(key, ct)
'ËË\x9c²*x'
ASCII and Latin-1 text round-trips fine, so the bug is easy to miss with English-only examples.
Steps to reproduce
python - <<'EOF'
from ciphers.des_ecb import Des
key = "0123456789abcdef"
print(Des.decrypt(key, Des.encrypt(key, "€100")) == "€100") # prints False
print(Des.decrypt(key, Des.encrypt(key, "hello")) == "hello") # prints True
EOF
Suspected cause
Operations.string_to_bitset builds the bitset with format(ord(char), "08b") (ciphers/des_ecb.py:151). The 08b format is a minimum width, so for ord(char) > 255 it emits more than 8 bits — e.g. "€" (U+20AC) becomes 14 bits. That shifts every subsequent bit off the 8-bit boundary that the block partitioning, padding, and bitset_to_string/bitset_to_hex conversions rely on, so the ciphertext for such text can no longer be decoded into the original string. Clamping to one byte (e.g. raising a ValueError for non-Latin-1 input, or encoding to UTF-8 bytes first) would keep the round-trip honest.
- Linguagem predominante
- Python
- Estrelas
- 225k
- Forks
- 51.2k
- Merge médio
- 1d 8h
- PRs com merge (30d)
- 40
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais 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 crashTalvez já em andamento @Nate-br assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
TheAlgorithms/Python#15636 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
other/password.py: alternative_password_generator ignores the requested length when the required characters exceed itTalvez já em andamento @raaj-2222 assumiu há 1 dia. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
TheAlgorithms/Python#15633 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
ciphers/base58.py is a copy of base64_cipher.py — no Base58 implementation exists in the fileTalvez já em andamento @SakshiYeole assumiu há 2 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 45/100
TheAlgorithms/Python#15637 ·
Mantenedores costumam responder em até 1 dia
-
hashes/adler32.py: checksum diverges from the Adler-32 spec for any non-ASCII input (sums Unicode code points instead of bytes)Talvez já em andamento @SwetaKumari7 assumiu há 2 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 35/100
TheAlgorithms/Python#15635 ·
Mantenedores costumam responder em até 1 dia
-
Optimize Node.has_loop to use constant auxiliary space instead of O(N) spaceTalvez já em andamento @mohitjoshi-hey assumiu há 12 dias. Abertaenhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 15/100
TheAlgorithms/Python#15576 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de TheAlgorithms/Python
Issues semelhantes
-
area/config comp/tools P2 platform/telegram type/bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
NousResearch/hermes-agent#145412 ·
Mantenedores costumam responder em até 1 dia
-
[oblt-aw][autodoc] Update docs for security org scaffolding and Docs AI menu permission changesTalvez já em andamento @github-actions assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
Community project: hosted MOSS-Image studio with a visual JSON layout builder (no ComfyUI needed)Aberta
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 65/100
OpenMOSS/MOSS-Image#27 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
deepspeedai/DeepSpeed#8925 · 1 comentário ·
Mantenedores costumam responder em até 3 dias
-
external integration integration-submission
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
langchain-ai/docs#7077 ·
Mantenedores costumam responder em até 1 dia