Implementation of modhex encoding, which uses keyboard-independent characters.
hex digit: 0123456789abcdef
modhex digit: cbdefghijklnrtuv
Encode a string of bytes as modhex.
>>> modhex(b'abcdefghijklmnop') == b'hbhdhehfhghhhihjhkhlhnhrhthuhvic'
True
Decode a modhex string to its binary form.
>>> unmodhex(b'hbhdhehfhghhhihjhkhlhnhrhthuhvic') == b'abcdefghijklmnop'
True
Returns True iff the given string is valid modhex.
>>> is_modhex(b'cbdefghijklnrtuv')
True
>>> is_modhex(b'cbdefghijklnrtuvv')
False
>>> is_modhex(b'cbdefghijklnrtuvyy')
False
Convert a string of hex digits to a string of modhex digits.
>>> hex_to_modhex(b'69b6481c8baba2b60e8f22179b58cd56') == b'hknhfjbrjnlnldnhcujvddbikngjrtgh'
True
>>> hex_to_modhex(b'6j')
Traceback (most recent call last):
...
ValueError: Illegal hex character in input
Convert a string of modhex digits to a string of hex digits.
>>> modhex_to_hex(b'hknhfjbrjnlnldnhcujvddbikngjrtgh') == b'69b6481c8baba2b60e8f22179b58cd56'
True
>>> modhex_to_hex(b'hbhdxx')
Traceback (most recent call last):
...
ValueError: Illegal modhex character in input
CRC16 implementation for Yubico OTP.