base32-fs
This crate implements a variant of BASE32 encoding for hashes that are used as file names: no two encoded hashes can be decoded to the same original hash unless there is a hash collision.
To achieve that the crate
- uses the same characters when encoding and decoding the data
as opposed to the original Crockford's alphabet that permits e.g. both "a" and "A" to be decoded to
10; - doesn't zero-extend invalid input lengths when decoding.
Besides that the crate
- uses only lowercase letters instead of uppercase as the most common representation of hashes;
- doesn't use padding characters;
- doesn't change the sorting order of the encoded data;
- doesn't use lookup table when decoding.
Usage
Encode into PathBuf
use PathBuf;
use ;
let input = *b"hello";
let mut output = with_capacity;
encode;
assert_eq!;
Decode from PathBuf
use Path;
use ;
let input = new;
let mut output: = Vecnew;
decode;
assert_eq!;
Encode into Vec<u8>
use ;
let input = *b"hello";
let mut output: = Vecwith_capacity;
encode;
let string = from_utf8.expect;
assert_eq!;
Decode from &[u8]
use Path;
use ;
let input = b"d1jprv3f";
let mut output: = Vecwith_capacity;
decode;
assert_eq!;