feat: move hash functions to dedicated hashing module and add MD5#1033
Merged
siriak merged 1 commit intoTheAlgorithms:masterfrom Apr 8, 2026
Merged
feat: move hash functions to dedicated hashing module and add MD5#1033siriak merged 1 commit intoTheAlgorithms:masterfrom
siriak merged 1 commit intoTheAlgorithms:masterfrom
Conversation
Contributor
Author
|
@siriak, this is ready to be merged. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1033 +/- ##
==========================================
+ Coverage 95.98% 96.00% +0.01%
==========================================
Files 389 390 +1
Lines 29520 29605 +85
==========================================
+ Hits 28335 28421 +86
+ Misses 1185 1184 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated hashing/ module to separate one-way hash algorithms from reversible ciphers, and adds a new MD5 implementation alongside existing SHA/BLAKE hashing algorithms.
Changes:
- Added
src/hashing/module and exposed it viasrc/lib.rs - Moved existing hash implementations (SHA-1/SHA-2/SHA-3/BLAKE2b + hashing traits) out of
ciphers/intohashing/ - Added a pure-Rust MD5 implementation (plus hex helper) and updated
DIRECTORY.md
Reviewed changes
Copilot reviewed 5 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/lib.rs |
Exposes the new hashing module from the crate root. |
src/hashing/mod.rs |
Defines the hashing module and re-exports hashing APIs (including MD5). |
src/hashing/md5.rs |
Adds MD5 + md5_hex with RFC test vectors. |
src/hashing/sha1.rs |
SHA-1 implementation relocated under hashing. |
src/hashing/sha2.rs |
SHA-2 family implementation relocated under hashing. |
src/hashing/sha3.rs |
SHA-3 implementation relocated under hashing. |
src/hashing/blake2b.rs |
BLAKE2b implementation relocated under hashing. |
src/hashing/hashing_traits.rs |
Hashing traits + HMAC relocated under hashing. |
src/ciphers/mod.rs |
Removes hashing modules/re-exports from ciphers. |
DIRECTORY.md |
Updates directory listing to reflect the new hashing module and MD5. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
siriak
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds an MD5 hash function implementation (
src/hashing/md5.rs) and moves all existing hash functions out ofsrc/ciphers/into a new dedicatedsrc/hashing/module.Why the restructure: Hash functions are fundamentally different from ciphers — they are one-way and non-reversible. Keeping them in
ciphers/was misleading. This change mirrors how the repository already separates concerns intosorting/,graph/,data_structures/, etc.MD5 implementation: A pure-Rust implementation following RFC 1321. It processes input in 512-bit blocks across four rounds of 16 operations each, using precomputed sine-derived constants (K table) and per-round bit-shift amounts (S table), producing a 128-bit (16-byte) little-endian digest.
Files changed:
src/hashing/md5.rs— new MD5 implementationsrc/hashing/mod.rs— new module, re-exports all hash functionssrc/ciphers/mod.rs— removed hashing entriessrc/lib.rs— addedpub mod hashingblake2b.rs,sha1.rs,sha2.rs,sha3.rs,hashing_traits.rs→src/hashing/Type of change
Checklist
cargo clippy --all -- -D warningsjust before my last commit and fixed any issue that was found.cargo fmtjust before my last commit.cargo testjust before my last commit and all tests passed.mod.rsfile within its own folder, and in any parent folder(s).DIRECTORY.mdwith the correct link.CONTRIBUTING.mdand my code follows its guidelines.