diff --git a/COBS/cobsDecode.py b/COBS/cobsDecode.py new file mode 100644 index 0000000..e6e4457 --- /dev/null +++ b/COBS/cobsDecode.py @@ -0,0 +1,17 @@ +class DecodeError(Exception): + pass + +def decode(data): + data = bytearray.fromhex(data) + length = len(data) + index = 0 + if length <= 0: + raise DecodeError("error with input") + while index < length - 2: + next = data[index] + data[index] = 0 + index += next + del data[0] + del data[length - 2] + + return bytearray.hex(data) \ No newline at end of file