Expand description
SIMD-accelerated base94 codec: binary data in printable ASCII.
Each byte b maps to (b - kf) mod 256; mixed values >= 93 escape into
two chars (0x7D/0x7E leader + follower) so every emitted char stays in
0x20..=0x7E and the output is at most 2x the input. kf is a key-mixing
parameter (only its low byte participates); pass 0 for the plain codec.
The format is a faithful port of openppp2 ppp/cryptography/ssea.cpp.
Performance notes (wire output unchanged):
- encode/decode run SIMD fast paths over 16-byte blocks (see
simd): the decoder solves the leader/follower alternation and escape reconstruction in-register and compacts leaders via a byte-shuffle LUT (pshufb on x86_64, vqtbl1 on aarch64; ~3x over scalar); the encoder precomputes interleaved leader/follower pairs and deletes non-escape followers through the same LUT (~2.5x). - Invalid input and sub-block tails fall back to the scalar reference loop, so error semantics stay bit-exact (pinned by fuzz + unit tests).
Structs§
- Decode
Error - The input contains characters outside the printable alphabet or a truncated/overflowing escape sequence.
Constants§
- DECIMAL_
MAX_ LEN - Max digits of a u64 in base 94 (94^10 > 2^64 > 94^9).
- SYMBOL_
COUNT - Number of printable symbols: 0x20..=0x7E.
Functions§
- decimal_
decode - Parses base94 digits (produced by
decimal_encode, possibly zero-padded with 0x20 chars) back into a u64. - decimal_
encode - Minimal-length base94 digits of
v; returns the digit count written. - decode_
into - Decodes base94 text (see
encode_into) and appends the bytes toout. On invalid inputoutis left unchanged and an error is returned. - encode_
into - Encodes binary bytes into printable 0x20..=0x7E chars, appending to
out. - encoded_
len - Number of chars
encode_intowould emit forsrc.