I am doing an integration and I have the following condition for a field:
If the length of the data is odd, the low nibble of the last byte is assigned the value hex 'F'. This hex 'F' for padding ensures that a whole number of bytes are used for the field and is not included in the length of the item.
I tried appending the hex F, but this is wrong:
data << "%X" % 15
I suppose I need to get the last byte and perform some magic on it, probably some bitwise operation:
low_nibble = data.bytes.last.get_low_nibble
low_nibble = transform_low_nibble_to_hex
data << low_nibble
I will be glad if someone can point me in the right direction.