feat: add Vernam cipher implementation#984
Merged
siriak merged 1 commit intoTheAlgorithms:masterfrom Dec 31, 2025
Merged
Conversation
Contributor
Author
|
@siriak, this is ready to be merged. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #984 +/- ##
==========================================
+ Coverage 95.77% 95.80% +0.02%
==========================================
Files 354 355 +1
Lines 23407 23528 +121
==========================================
+ Hits 22419 22540 +121
Misses 988 988 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
siriak
approved these changes
Dec 31, 2025
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
This PR adds an implementation of the Vernam cipher (also known as a simple substitution cipher using modular arithmetic) to the ciphers module. The Vernam cipher is a symmetric stream cipher that combines plaintext with a key using modular addition and subtraction.
Implementation Details
The implementation provides two public functions:
vernam_encrypt(plaintext: &str, key: &str) -> Stringvernam_decrypt(ciphertext: &str, key: &str) -> StringAlgorithm Details
Security Note
This implementation is for educational purposes. In practice, the Vernam cipher is only secure when:
Changes Made
src/ciphers/vernam.rswith complete implementationsrc/ciphers/mod.rsto include and export the new moduleType of Change
Testing
All tests pass successfully:
Test Coverage
Examples
Checklist
cargo fmtcargo clippy