Like Base64, but encodes four bytes of binary into five characters of ASCII, achieving a 25% increase instead of 33%. Unlike Base64, though, it doesn't have a single most-used variant. This crate implements the four most common, plus a variant suitable for use as filenames, and has an option for a custom character set.
The crate is designed following the Base64 implementation in the
Standard Library. Because it is outside the stdlib, though, it provides
methods on the base85::Config
struct:
extern crate base85;
let codec = base85::Z85; // See below for variants, or construct your own:
let custom = base85::Config {
char_set: base85::Filename,
all_zero: None,
line_length: Some(123)
};
let plain = "Hello world";
let encoded = codec.from_str(&plain_text);
let decoded = codec.to_str(&encoded);
assert_eq!(plain, decoded);
ASCII85
- Adobe's variant for PostScriptBTOA
- Original by Paul E. RutterFILENAME
- Z85 variant for use in filenamesRFC1924
- Esoteric variant "for IPv6"Z85
- Variant used in ZeroMQ
- Wikipedia
- Adobe PostScript Reference
- Btoa and Atob source code
- Z85 specification
- RFC1924 - (Yes, this is an April Fools')
- Javascript implementation
- Public Domain
- Pull requests welcome
- Say hi! :D