code: def hotp_truncate(hmac_result, length=6):
      
      if len(hmac_result) != 20:
          raise yubico_exception.YubicoError("HMAC-SHA-1 not 20 bytes long")
      offset   =  ord_byte(hmac_result[19]) & 0xf
      bin_code = (ord_byte(hmac_result[offset]) & 0x7f) << 24 \
          | (ord_byte(hmac_result[offset+1]) & 0xff) << 16 \
          | (ord_byte(hmac_result[offset+2]) & 0xff) <<  8 \
          | (ord_byte(hmac_result[offset+3]) & 0xff)
      return bin_code % (10 ** length)
docs: Perform the HOTP Algorithm truncating.
  
      Input is a bytestring.