YubiOTP Utilities¶
yubiotp.modhex¶
Implementation of modhex encoding, which uses keyboard-independent characters.
hex digit: 0123456789abcdef
modhex digit: cbdefghijklnrtuv
-
yubiotp.modhex.
modhex
(data)[source]¶ Encode a string of bytes as modhex.
>>> modhex(b'abcdefghijklmnop') == b'hbhdhehfhghhhihjhkhlhnhrhthuhvic' True
-
yubiotp.modhex.
unmodhex
(encoded)[source]¶ Decode a modhex string to its binary form.
>>> unmodhex(b'hbhdhehfhghhhihjhkhlhnhrhthuhvic') == b'abcdefghijklmnop' True
-
yubiotp.modhex.
is_modhex
(encoded)[source]¶ Returns
True
iff the given string is valid modhex.>>> is_modhex(b'cbdefghijklnrtuv') True >>> is_modhex(b'cbdefghijklnrtuvv') False >>> is_modhex(b'cbdefghijklnrtuvyy') False
-
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.
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.