Module nixbase32

Source
Expand description

Implements the slightly odd “base32” encoding that’s used in Nix.

Nix uses a custom alphabet. Contrary to other implementations (RFC4648), encoding to “nix base32” doesn’t use any padding, and reads in characters in reverse order.

This is also the main reason why we can’t use data_encoding::Encoding - it gets things wrong if there normally would be a need for padding.

Constants§

ALPHABET 🔒
BASE32_ORD 🔒
This maps a nixbase32-encoded character to its binary representation, which is also the index of the character in the alphabet. Invalid characters are mapped to 0xFF, which is itself an invalid value.

Functions§

decode
Returns decoded input
decode_fixed
decode_inner 🔒
decode_len
Returns the decoded length of an input of length len.
encode
Returns encoded input
encode_len
Returns the encoded length of an input of length len
find_invalid 🔒