ciphers/des_ecb.py: encrypt/decrypt silently corrupts any character above U+00FF (round-trip fails)
メンテナーはふだん 1 日以内に返信
@mohammedanasnakhuda がすでに取り組んでいます。
2026年10月25日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- cryptography
調査の方向性
ciphers/des_ecb.py の Operations.string_to_bitset(151 行目付近)から始めてください。ここでは format(ord(char), "08b") が U+00FF を超えるコードポイントに対して 8 ビットを超えて出力し、ビットストリーム全体がバイト境界からずれます。報告者は、非 Latin-1 の入力に対して ValueError を発生させるか、先に UTF-8 バイトへエンコードするかのどちらかを提案しています。encrypt/decrypt が有効なラウンドトリップとして成立するのはどちらかを決めてください。issue 内の python ワンライナーで再現し、エンコード処理を修正して、ASCII、Latin-1、"€100" や "日本語" のようなマルチバイト文字列のラウンドトリップを検証してください。ラウンドトリップの一致を assert する小さなテストがあれば完了とみなせます。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 225k
- フォーク
- 51.2k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 40
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TheAlgorithms/Python のほかの issue
-
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 crash対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
TheAlgorithms/Python#15636 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
other/password.py: alternative_password_generator ignores the requested length when the required characters exceed it対応中かも @raaj-2222 が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
TheAlgorithms/Python#15633 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ciphers/base58.py is a copy of base64_cipher.py — no Base58 implementation exists in the file対応中かも @SakshiYeole が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
TheAlgorithms/Python#15637 ·
メンテナーはふだん 1 日以内に返信
-
hashes/adler32.py: checksum diverges from the Adler-32 spec for any non-ASCII input (sums Unicode code points instead of bytes)対応中かも @SwetaKumari7 が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
TheAlgorithms/Python#15635 ·
メンテナーはふだん 1 日以内に返信
-
Optimize Node.has_loop to use constant auxiliary space instead of O(N) space対応中かも @mohitjoshi-hey が 12 日前に担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 15/100
TheAlgorithms/Python#15576 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
TheAlgorithms/Python の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
btclib-org/btclib-node#2083 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Gathin23/cleanyourtv#2089 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
jxxghp/MoviePilot#7212 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
cli dx rust
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
NekomyaDev/nudge#278 ·
メンテナーはふだん 1 日以内に返信