Use Base32 encoding and decoding
mainThe Base32 class in the SimpleBase namespace provides various methods to encode binary data or numbers into Base32 strings and decode them back. It supports multiple encoding flavors (alphabets) through static properties and allows for custom alphabets via constructors.
Common tasks include:
- Encoding
bytespans orlong/ulongnumbers into strings. - Decoding Base32 strings back into
bytearrays. - Stream-based encoding and decoding for large datasets.
- Non-allocating operations using
TryEncodeandTryDecodewithSpan<T>for high performance.
// Example: Encoding bytes to a string using RFC 4648
byte[] data = { 0x01, 0x02, 0x03 };
string encoded = Base32.Rfc4648.Encode(data);
// Example: Decoding a string back to bytes
byte[] decoded = Base32.Rfc4648.Decode(encoded);