RustCrypto / formats

Cryptography-related format encoders/decoders: DER, PEM, PKCS, PKIX
243 stars 129 forks source link

base32ct: add const encoded_len fn #1424

Closed dodomorandi closed 4 months ago

dodomorandi commented 4 months ago

This can be handy to avoid an heap allocation, because it is possible to use the result of the const fn to allocate an array of the right size.

EDIT: I changed a bit the initial proposal in order to make it actually easier to use in const context. Previously encoded_len took a slice (like in the trait), now it takes an usize representing the number of bytes to encode.