| Crates.io | base32-fs |
| lib.rs | base32-fs |
| version | 0.1.3 |
| created_at | 2025-04-15 19:23:03.293166+00 |
| updated_at | 2025-08-21 22:25:44.274763+00 |
| description | A variant of BASE32 encoding for hashes that are used as file names |
| homepage | https://github.com/igankevich/base32-fs |
| repository | https://github.com/igankevich/base32-fs |
| max_upload_size | |
| id | 1635068 |
| size | 46,716 |
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
10;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.
PathBufuse std::path::PathBuf;
use base32_fs::{encode, encoded_len, PathBufOutput};
let input = *b"hello";
let mut output = PathBufOutput::with_capacity(encoded_len(input.len()));
encode(&input, &mut output);
assert_eq!(PathBuf::from("d1jprv3f"), output.into_path_buf());
PathBufuse std::path::Path;
use base32_fs::{decode, decoded_len, PathBufInput};
let input = PathBufInput::new(Path::new("d1jprv3f"));
let mut output: Vec<u8> = Vec::new();
decode(input, &mut output);
assert_eq!(b"hello", output.as_slice());
Vec<u8>use base32_fs::{encode, encoded_len};
let input = *b"hello";
let mut output: Vec<u8> = Vec::with_capacity(encoded_len(input.len()));
encode(&input, &mut output);
let string = std::str::from_utf8(output.as_slice()).expect("Always a valid UTF-8 byte sequence");
assert_eq!("d1jprv3f", string);
&[u8]use std::path::Path;
use base32_fs::{decode, decoded_len, PathBufInput};
let input = b"d1jprv3f";
let mut output: Vec<u8> = Vec::with_capacity(decoded_len(input.len()).unwrap());
decode(input.as_slice(), &mut output);
assert_eq!(b"hello", output.as_slice());