feat: add Gronsfeld cipher implementation#1045
Conversation
Implements encrypt and decrypt functions for the Gronsfeld cipher, a Vigenère variant where the key is a digit sequence (0-9). Includes 20 tests covering key validation, case preservation, alphabet wrap-around, and round-trip correctness.
|
@siriak Hi, can you take a look at this PR in your convenience time. Thank you |
There was a problem hiding this comment.
Pull request overview
Adds a new Gronsfeld cipher implementation to the ciphers module, exposing encrypt/decrypt APIs and accompanying unit tests.
Changes:
- Introduce
gronsfeld_encrypt/gronsfeld_decryptwith key validation and ASCII letter shifting. - Add unit tests for key validation, case preservation, wrap-around, and round-trip behavior.
- Wire the new module into
src/ciphers/mod.rsfor compilation and public re-export.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ciphers/mod.rs | Registers the new gronsfeld module and re-exports its public functions. |
| src/ciphers/gronsfeld.rs | Implements Gronsfeld encrypt/decrypt logic plus unit tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1045 +/- ##
==========================================
- Coverage 95.82% 95.81% -0.02%
==========================================
Files 393 394 +1
Lines 29971 30084 +113
==========================================
+ Hits 28721 28825 +104
- Misses 1250 1259 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
siriak
left a comment
There was a problem hiding this comment.
Please review Copilot's comments, everything else looks good
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@siriak I've just fixed. I think it's ready to be merged |
syntax error Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Description
This PR adds a Gronsfeld Cipher implementation to the ciphers module.
About Gronsfeld Cipher
The Gronsfeld cipher, a Vigenère variant where the key is a digit sequence (0-9). Includes 20 tests covering key validation, case preservation, alphabet wrap-around, and round-trip correctness.
Implementation Details
The implementation provides two public functions:
gronsfeld_encrypt(text: &str, key: &str) -> Result<String, &'static str>gronsfeld_decrypt(text: &str, key: &str) -> Result<String, &'static str>gronsfeld_encrypt:decrypt(encrypt(text, key), key) == textAlgorithm Details
"31415"or"9876543210"Testing
All tests pass and the codebase is clean:
cargo test gronsfeld cargo fmt --check cargo clippy -- -D warningsTest Coverage
"abc"+"123"="bdf"'z'+ 1 ='a'"Hello, World!"+"5"="Mjqqt, Btwqi!""bdf"+"123"="abc"'a'- 1 ='z'Examples
Checklist
cargo fmtcargo clippy