Function decode [src]
Decodes a hexadecimal string into a binary buffer.
The output buffer must be half the size of the input buffer.
Prototype
pub fn decode(bin: []u8, encoded: []const u8) error{ SizeMismatch, InvalidCharacter, InvalidPadding }!void Parameters
bin: []u8encoded: []const u8 Possible Errors
Source
pub fn decode(bin: []u8, encoded: []const u8) error{ SizeMismatch, InvalidCharacter, InvalidPadding }!void {
if (encoded.len % 2 != 0) {
return error.InvalidPadding;
}
if (bin.len < encoded.len / 2) {
return error.SizeMismatch;
}
_ = decodeAny(bin, encoded, null) catch |err| {
switch (err) {
error.InvalidCharacter => return error.InvalidCharacter,
error.InvalidPadding => return error.InvalidPadding,
else => unreachable,
}
};
}