def hotp(key, counter, digits=6):

    msg = struct.pack('>Q', counter)
    hs = hmac.new(key, msg, hashlib.sha1).digest()
    offset = six.indexbytes(hs, 19) & 0x0f
    val = struct.unpack('>L', hs[offset:offset + 4])[0] & 0x7fffffff
    return '{val:0{digits}d}'.format(val=val % 10 ** digits, digits=digits)
Set reference.
dataset/ETHPy150Open gavinwahl/django-u2f/django_u2f/oath.py/hotp--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/db/__init__.py/ReferenceProperty.__set__