| Crates.io | harmonia-utils-base-encoding |
| lib.rs | harmonia-utils-base-encoding |
| version | 0.0.0-alpha.0 |
| created_at | 2026-01-23 17:21:20.907531+00 |
| updated_at | 2026-01-23 17:21:20.907531+00 |
| description | Base encoding utilities for Harmonia (Nix base32, hex, base64) |
| homepage | https://github.com/nix-community/harmonia |
| repository | https://github.com/nix-community/harmonia.git |
| max_upload_size | |
| id | 2065068 |
| size | 38,908 |
Base encoding/decoding utilities for the various encodings Nix uses.
This crate provides encoding and decoding for the base encodings used by Nix, including the special Nix base32 alphabet. It is a standalone crate that can be used by any project needing Nix-compatible encoding.
base32 - Nix base32 encoding (special 32-character alphabet, LSB first, reversed)Base - Enum for selecting encoding format (Hex, NixBase32, Base64)decode_for_base / encode_for_base - Get encode/decode functions for a given basebase64_len - Calculate base64 encoded length// Nix base32 encoding
pub mod base32 {
pub fn encode_string(input: &[u8]) -> String;
pub fn decode_mut(input: &[u8], output: &mut [u8]) -> Result<usize, DecodePartial>;
}
// Base encoding selection
pub enum Base { Hex, NixBase32, Base64 }
pub fn decode_for_base(base: Base) -> impl Fn(&[u8], &mut [u8]) -> Result<usize, DecodePartial>;
Nix uses a non-standard base32 encoding:
0123456789abcdfghijklmnpqrsvwxyz (no e, o, t, u)This matches the encoding used in Nix store paths.