YubiOTP Utilities¶
yubiotp.modhex¶
Implementation of modhex encoding, which uses keyboard-independent characters.
hex digit: 0123456789abcdef
modhex digit: cbdefghijklnrtuv
- yubiotp.modhex.hex_to_modhex(hex_str)[source]¶
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
- yubiotp.modhex.is_modhex(encoded)[source]¶
Returns
Trueiff the given string is valid modhex.>>> is_modhex(b'cbdefghijklnrtuv') True >>> is_modhex(b'cbdefghijklnrtuvv') False >>> is_modhex(b'cbdefghijklnrtuvyy') False
- yubiotp.modhex.modhex(data)[source]¶
Encode a string of bytes as modhex.
>>> modhex(b'abcdefghijklmnop') == b'hbhdhehfhghhhihjhkhlhnhrhthuhvic' True
- yubiotp.modhex.modhex_to_hex(modhex_str)[source]¶
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
yubiotp.crc¶
CRC16 implementation for Yubico OTP.