Python provides a pretty handy module for performin MD5 sums of both text and data buffers. The following function provides an MD5 sum given a file name:

def get_hash(self, filename):
  """
        Generates an md5 sum of a file
  """
  f = file(filename,'rb');
  m = md5.new();
  readBytes = 1024; # read 1024 bytes per time
  totalBytes = 0;
  while (readBytes):
      readString = f.read(readBytes);
      m.update(readString);
      readBytes = len(readString);
      totalBytes+=readBytes;
  f.close();
  return m.hexdigest();