def ParseFilePacket(f, header):
 nothing = (None, None)
 if (header != 'PAR2\x00PKT'):
  return nothing
 len = struct.unpack('<Q', f.read(8))[0]
 if (((int((len / 4)) * 4) != len) or (len < 20)):
  return nothing
 md5sum = f.read(16)
 data = f.read((len - 32))
 md5 = new_md5()
 md5.update(data)
 if (md5sum != md5.digest()):
  return nothing
 for offset in range(0, len, 8):
  if (data[offset:(offset + 16)] == 'PAR 2.0\x00FileDesc'):
   hash = data[(offset + 32):(offset + 48)]
   filename = data[(offset + 72):].strip('\x00')
   return (filename, hash)
 return nothing

def ParseFilePacket ( f , header ) : nothing = ( None , None ) if ( header != 'PAR2\x00PKT' ) : return nothing len = struct . unpack ( '<Q' , f . read ( 8 ) ) [ 0 ] if ( ( ( int ( ( len / 4 ) ) * 4 ) != len ) or ( len < 20 ) ) : return nothing md5sum = f . read ( 16 ) data = f . read ( ( len - 32 ) ) md5 = new_md5 ( ) md5 . update ( data ) if ( md5sum != md5 . digest ( ) ) : return nothing for offset in range ( 0 , len , 8 ) : if ( data [ offset : ( offset + 16 ) ] == 'PAR 2.0\x00FileDesc' ) : hash = data [ ( offset + 32 ) : ( offset + 48 ) ] filename = data [ ( offset + 72 ) : ] . strip ( '\x00' ) return ( filename , hash ) return nothing
look up and analyze a filedesc package .