$ show apache/commons-codec
Apache Commons Codec is a mature Java library providing a comprehensive set of encoders and decoders for binary-to-text formats (Base16, Base32, Base64, Base45, Base58, Hex), digest and hash algorithms (MD5, SHA-1/2/3, MurmurHash, XXHash32, Blake3, CRC16/32), phonetic encoding (Soundex, Metaphone, Caverphone, Beider-Morse, Daitch-Mokotoff), and network codecs (URL encoding, Quoted-Printable, RFC 1522 MIME). The architecture is modular with clear package separation: `binary`, `digest`, `language`, `net`, and `cli`. Key design patterns include a builder pattern for configuring codecs (e.g., `Base64.builder()`), an abstract base class `BaseNCodec` with streaming support via `BaseNCodecInputStream`/`OutputStream`, and a `CodecPolicy` enum for strict vs. lenient decoding. The library has no production dependencies; only test dependencies on commons-lang3 and commons-io. It is widely used across the Java ecosystem, with extensive test coverage including RFC vectors and backward compatibility tests. However, some deprecated methods and known bugs (e.g., in MurmurHash3 legacy methods) are preserved for compatibility, and certain algorithms (SHAKE) require Java 25, introducing version drift.
The LLM identified 4 files worth highlighting for reuse:
Abstract base class for all binary codecs (Base16, Base32, Base64, Base45, Base58). Defines a reusable encoding/decoding pipeline with a `Context` inner class for streaming state, an `AbstractBuilder` for configuration, and methods for chunking, padding, and strict decoding validation. This class is self-contained (only imports java.nio and java.util) and can be extended to implement new base-N codecs with minimal effort.
A `FilterInputStream` that wraps any `BaseNCodec` subclass to perform encoding or decoding on the fly. It uses the codec's `Context` to manage buffering and modulus state. This pattern is reusable for any streaming codec and can be extracted as a generic streaming adapter for byte-to-byte transformations.
A simple enum with two values (`STRICT` and `LENIENT`) that controls decoding behavior across multiple codecs. It is used to reject malformed input (e.g., invalid padding, trailing bits) in strict mode. This is a clean, reusable configuration pattern that can be applied to any codec or parser requiring validation policies.
Implementation of MurmurHash3 32-bit and 128-bit hash functions, including incremental hashing via `IncrementalHash32x86`. Provides static factory methods and a builder-like API for seed and configuration. Despite deprecated legacy methods with known bugs, the corrected implementations (`hash32x86`, `hash128x64`) are self-contained and can be extracted for use in hash-based data structures or checksums.