def hotp(key,counter,format='<STR_LIT>',hash=hashlib.sha1):
bin_hotp = __hotp(key, counter, hash)<EOL>if format == '<STR_LIT>':<EOL><INDENT>return dec(bin_hotp, <NUM_LIT:4>)<EOL><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>return dec(bin_hotp, <NUM_LIT:6>)<EOL><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>return dec(bin_hotp, <NUM_LIT:7>)<EOL><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>return dec(bin_hotp, <NUM_LIT:8>)<EOL><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>return '<STR_LIT>' % truncated_value(bin_hotp)<EOL><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>return _utils.tohex(bin_hotp)<EOL><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>return bin_hotp<EOL><DEDENT>elif format == '<STR_LIT>':<EOL><INDENT>return str(truncated_value(bin_hotp))<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>
Compute a HOTP value as prescribed by RFC4226

:param key:
    the HOTP secret key given as an hexadecimal string
:param counter:
    the OTP generation counter
: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 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).

Examples:

 >>> hotp('343434', 2, format='dec6')
     '791903'