title: Calculating MD5 of Hex in Python
body: <p>I always fail with the decrypting of a RC4 encrypted object. My key has to be the MD5-Hash of this hex string:</p>
  
  <pre><code>00 00 00 01 3e 2a 5b 71 00 00 03 a0
  </code></pre>
  
  <p>What i tried was to convert that hex string to ascii and calculate afterwards the MD5 hash of it, but it seems like my key is always wrong. I think there is a problem because some of the hex values are control characters, but how is then the correct way to calculate the MD5 of this hex string ? What i thought of was something like this:</p>
  
  <pre><code>from Crypto.Cipher import ARC4
  from Crypto.Hash import MD5
  
  
  def hexToAscii(hex_string):
      return ''.join([chr(int(''.join(c), 16)) for c in zip(hex_string[0::2],hex_string[1::2])])
  
  def main():
      hex_string = '000000013e2a5b71000003a0'
  
      # Key for Decryption
      myKey = MD5.new(hexToAscii(hex_string)).hexdigest()
  
      print 'hexToAscii(hex_string): %s' % hexToAscii(hex_string)
  
      #open('myfile','wb').write(ARC4.new(hexToAscii(myKey)).decrypt(hexToAscii(CIPHER_TEXT)))
  
  if __name__ == '__main__':
      main()
  </code></pre>