feat: add base32 cipher implementation#991
Merged
siriak merged 3 commits intoTheAlgorithms:masterfrom Jan 7, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #991 +/- ##
==========================================
+ Coverage 95.86% 95.93% +0.06%
==========================================
Files 360 361 +1
Lines 24476 24613 +137
==========================================
+ Hits 23465 23613 +148
+ Misses 1011 1000 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
@siriak, this is ready to be merged. |
siriak
approved these changes
Jan 7, 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
This PR adds an implementation of Base32 encoding and decoding to the ciphers module. Base32 is a binary-to-text encoding scheme that represents binary data using 32 ASCII characters (A-Z and 2-7), following RFC 4648 specifications.
Implementation Details
The implementation provides two public functions:
1.
base32_encode(data: &[u8]) -> Vec<u8>2.
base32_decode(data: &[u8]) -> Result<Vec<u8>, String>Resultwith descriptive error messagesAlgorithm Details
write!macro instead offormat!for better performanceUse Cases
Base32 is commonly used when:
Changes Made
src/ciphers/base32.rswith complete implementationsrc/ciphers/mod.rsto include and export the new modulewrite!instead offormat!)Type of Change
Test Coverage
b"Hello World!"→b"JBSWY3DPEBLW64TMMQQQ===="b"JBSWY3DPEBLW64TMMQQQ====""→b"Hello World!"b"123456"→b"GEZDGNBVGY======"b"some long complex string"→b"ONXW2ZJANRXW4ZZAMNXW24DMMV4CA43UOJUW4ZY="Examples
Performance Optimizations
write!macro instead offormat!in loops (avoids intermediate allocations)is_multiple_of()for clearer intentCode Quality
Checklist
cargo fmtcargo clippy