def vtcheck(md5, vtKey):
 vtUrl = 'https://www.virustotal.com/vtapi/v2/file/report'
 parameters = {'resource': md5, 'apikey': vtKey}
 try:
  data = urllib.urlencode(parameters)
  req = urllib2.Request(vtUrl, data)
  response = urllib2.urlopen(req)
  jsonResponse = response.read()
 except:
  return ((-1), 'The request to VirusTotal has not been successful')
 try:
  jsonDict = json.loads(jsonResponse)
 except:
  return ((-1), 'An error has occurred while parsing the JSON response from VirusTotal')
 return (0, jsonDict)

def vtcheck ( md5 , vtKey ) : vtUrl = 'https://www.virustotal.com/vtapi/v2/file/report' parameters = { 'resource' : md5 , 'apikey' : vtKey } try : data = urllib . urlencode ( parameters ) req = urllib2 . Request ( vtUrl , data ) response = urllib2 . urlopen ( req ) jsonResponse = response . read ( ) except : return ( ( - 1 ) , 'The request to VirusTotal has not been successful' ) try : jsonDict = json . loads ( jsonResponse ) except : return ( ( - 1 ) , 'An error has occurred while parsing the JSON response from VirusTotal' ) return ( 0 , jsonDict )
function to check a hash on virustotal and get the report summary .