def totp(key, format='<STR_LIT>', period=<NUM_LIT:30>, t=None, hash=hashlib.sha1):
if t is None:<EOL><INDENT>t = int(time.time())<EOL><DEDENT>else:<EOL><INDENT>if isinstance(t, datetime.datetime):<EOL><INDENT>t = calendar.timegm(t.utctimetuple())<EOL><DEDENT>else:<EOL><INDENT>t = int(t)<EOL><DEDENT><DEDENT>T = int(t/period)<EOL>return hotp(key, T, format=format, hash=hash)<EOL>
Compute a TOTP value as prescribed by OATH specifications.

:param key:
    the TOTP key given as an hexadecimal string
:param format:
    the output format, can be:
       - hex, for a variable length hexadecimal format,
       - hex-notrunc, for a 40 characters hexadecimal non-truncated format,
       - dec4, for a 4 characters decimal format,
       - dec6,
       - dec7, or
       - dec8
    it defaults to dec6.
:param period:
    a positive integer giving the period between changes of the OTP
    value, as seconds, it defaults to 30.
:param t:
    a positive integer giving the current time as seconds since EPOCH
    (1st January 1970 at 00:00 GMT), if None we use time.time(); it
    defaults to None;
:param hash:
    the hash module (usually from the hashlib package) to use,
    it defaults to hashlib.sha1.

:returns:
    a string representation of the OTP value (as instructed by the format parameter).
:type: str