Skip to content

feat: add Base85 (ASCII85) cipher implementation#1018

Merged
siriak merged 1 commit intoTheAlgorithms:masterfrom
AliAlimohammadi:add-base85-cipher
Feb 11, 2026
Merged

feat: add Base85 (ASCII85) cipher implementation#1018
siriak merged 1 commit intoTheAlgorithms:masterfrom
AliAlimohammadi:add-base85-cipher

Conversation

@AliAlimohammadi
Copy link
Contributor

Description

This PR adds an implementation of the Base85 (ASCII85) encoding and decoding cipher to the ciphers module.

Base85, also known as ASCII85, is a binary-to-text encoding scheme developed by Adobe Systems. It encodes 4 bytes of binary data into 5 ASCII characters, using characters in the range 33-117 ('!' to 'u'). This encoding is more efficient than Base64, producing approximately 25% less overhead.

Changes Made

  • ✅ Added base85.rs with base85_encode and base85_decode functions
  • ✅ Updated mod.rs to include the new base85 module and exports
  • ✅ Updated DIRECTORY.md to list the new cipher (alphabetically ordered)
  • ✅ Included comprehensive documentation with examples
  • ✅ Added unit tests including edge cases and roundtrip tests

Implementation Details

  • Encoding: Converts binary data to Base85 by processing 32-bit chunks
  • Decoding: Converts Base85 text back to binary data
  • Edge Cases: Properly handles empty input and padding requirements
  • Tests: Includes tests for empty strings, standard cases, and encode/decode roundtrips

Testing

All tests pass:

cargo test --lib ciphers::base85

Example usage:

use the_algorithms_rust::ciphers::{base85_encode, base85_decode};

let encoded = base85_encode(b"Hello");
let decoded = base85_decode(&encoded);
assert_eq!(decoded, b"Hello");

References

Checklist

  • Code follows the repository's style guidelines
  • Documentation includes examples and references
  • All tests pass
  • mod.rs updated with new module
  • DIRECTORY.md updated with new cipher
  • No warnings from cargo clippy
  • Code is formatted with cargo fmt

@AliAlimohammadi
Copy link
Contributor Author

@siriak, this is ready to be merged.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 99.07407% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.01%. Comparing base (43c7049) to head (6caca6b).

Files with missing lines Patch % Lines
src/ciphers/base85.rs 99.07% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1018      +/-   ##
==========================================
+ Coverage   95.99%   96.01%   +0.01%     
==========================================
  Files         382      383       +1     
  Lines       28744    28852     +108     
==========================================
+ Hits        27594    27702     +108     
  Misses       1150     1150              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit 39c6978 into TheAlgorithms:master Feb 11, 2026
7 checks passed
@AliAlimohammadi AliAlimohammadi deleted the add-base85-cipher branch February 11, 2026 20:36
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.

3 participants