decodedLenForSlice
Returns the decoded length of a hexadecimal string, ignoring any characters in the ignore list. This operation does not run in constant time, but it aims to avoid leaking information about the underlying hexadecimal string.
Function parameters
Parameters
- encoded:[]const u8
(best-effort) constant time hexadecimal encoding and decoding.
Types
Error sets in this namespace
Error Sets
Source
Implementation
pub fn decodedLenForSlice(decoder: DecoderWithIgnore, encoded: []const u8) !usize {
var hex_len = encoded.len;
for (encoded) |c| {
if (decoder.ignored_chars.isSet(c)) hex_len -= 1;
}
if (hex_len % 2 != 0) {
return error.InvalidPadding;
}
return hex_len / 2;
}