/ Published in: Python
URL: http://bit.ly/4jags
Convert to and from modHex as used by the yubikey from yubico.
Expand |
Embed | Plain Text
hexHexChars = '0123456789abcdef' modHexChars = 'cbdefghijklnrtuv' hex2ModDict = dict(zip(hexHexChars, modHexChars)) mod2HexDict = dict(zip(modHexChars, hexHexChars)) def modhex_encode(s): return ''.join( [ hex2ModDict[c] for c in s.encode('hex') ] ) # end def modhex_encode def modhex_decode(m): return ''.join( [ mod2HexDict[c] for c in m ] ).decode('hex') # end def modhex_decode
You need to login to post a comment.
