decodedLen
Returns the maximum possible decoded size for a given input length - The actual length may be less if the input includes padding.
InvalidPadding is returned if the input length is not valid.
Function parameters
Parameters
(best-effort) constant time hexadecimal encoding and decoding.
Types
Error sets in this namespace
Error Sets
Source
Implementation
pub fn decodedLen(b64_len: usize, variant: Variant) !usize {
var result = b64_len / 4 * 3;
const leftover = b64_len % 4;
if (variant.padding) {
if (leftover % 4 != 0) return error.InvalidPadding;
} else {
if (leftover % 4 == 1) return error.InvalidPadding;
result += leftover * 3 / 4;
}
return result;
}