Skip to main content

encode_array

Function encode_array 

Source
pub const fn encode_array<const OUT: usize>(
    data: &[u8],
    alphabet: Alphabet,
) -> [u8; OUT]
Expand description

Encodes data into a fixed-size array at compile time.

The generic parameter OUT is the output array length. It must be exactly the encoded length of data or a compile-time panic is raised.

ยงExample

const DATA: [u8; 5] = [0x68, 0x65, 0x6C, 0x6C, 0x6F];
const B32: [u8; 8] = base32::encode_array::<8>(&DATA, base32::Alphabet::Rfc4648);
assert_eq!(&B32, b"NBSWY3DP");