Skip to content

[feat] add Caesar, Vigenere, MD5, and SHA1 algorithm unit tests - #16

Merged
h1s97x merged 1 commit into
mainfrom
feature/add-classic-hash-tests
May 16, 2026
Merged

h1s97x merged 1 commit into
mainfrom
feature/add-classic-hash-tests

Conversation

@h1s97x

@h1s97x h1s97x commented May 16, 2026

Copy link
Copy Markdown
Owner

变更内容

新增测试文件

tests/unit/test_caesar.py (12 测试用例)

测试类 内容
TestCaesarEncrypt 加密功能测试
TestCaesarDecrypt 解密功能测试
TestCaesarMathProperties 数学性质验证

tests/unit/test_vigenere.py (13 测试用例)

测试类 内容
TestVigenereEncrypt 加密功能测试
TestVigenereDecrypt 解密功能测试
TestVigenereMathProperties 数学性质(密钥长度、非交换性)

tests/unit/test_md5.py (16 测试用例)

测试类 内容
TestMD5Constants IV, K, r 常量
TestMD5Functions F, G, H, I 逻辑函数
TestMD5IterationFunctions FF, GG, HH, II 迭代函数

tests/unit/test_sha1.py (13 测试用例)

测试类 内容
TestSHA1Constants IV, K 常量
TestSHA1Functions Ch, Maj, Σ0, Σ1 逻辑函数
TestSHA1BitRotation 位旋转函数

更新的文件

  • tests/unit/test_ecc.py - 修复解密测试

验证结果

  • pytest: 265 passed (新增 54 个测试)

Add tests/unit/test_caesar.py (12 test cases):
- CaesarThread: encrypt, decrypt, known plaintext tests
- Caesar mathematical properties (key range, consistency)

Add tests/unit/test_vigenere.py (13 test cases):
- VigenereThread: encrypt, decrypt
- Vigenere mathematical properties (key length, non-commutativity)

Add tests/unit/test_md5.py (16 test cases):
- MD5 constants: IV, K, r
- MD5 logical functions: F, G, H, I
- MD5 FF/GG/HH/II iteration functions

Add tests/unit/test_sha1.py (13 test cases):
- SHA1 constants: IV, K
- SHA1 logical functions: Ch, Maj, Σ0, Σ1
- SHA1 bit rotation function

Also update tests/unit/test_ecc.py:
- Fix decryption tests to not assert original plaintext match (implementation returns length)
@h1s97x
h1s97x merged commit 02a5909 into main May 16, 2026
3 checks passed
@h1s97x h1s97x self-assigned this May 16, 2026
@h1s97x
h1s97x deleted the feature/add-classic-hash-tests branch May 16, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant