title: Do different OS's affect the md5 checksum of a file in Python?
body: <p>So I have a python script that uses the pyserial library to send a file over serial to another computer. I wrote some script to calculate the md5 checksum of the file before and after being sent over serial and I have encountered some problems.</p>
  
  <p>Example:
   I sent a simple file named third.txt containing a list of numbers 1 through 10. Simple file, nothing fancy or large. The checksum of the file before transmitting is completely different than the checksum of the file after transmitting on the other computer, even though the files are clearly the same.</p>
  
  <p>I checked to see if there was something wrong with my code by simply moving the file over a USB and doing the checksum calulations this way. This time it worked.</p>
  
  <p>Any ideas why this is happening and how I might possibly fix it?</p>
  
  <p>Here is my checksum code before sending. This is not the exact code, but basically what I did.</p>
  
  <pre><code>&lt;&lt;Code that waits for command from client&gt;&gt;
  
  with open(file_loc) as file_to_read:
      data = file_to_read.read()
      md5a = hashlib.md5(data).hexdigest()
  ser.write('\n' + md5a + '\n') 
  </code></pre>
  
  <p>Here is my checksum code after sending.</p>
  
  <pre><code>with open(file_loc) as file_to_read:
      data = file_to_read.read()
      md5b = hashlib.md5(data).hexdigest()
  print('Sending Checksum Command')
  ser.write("\n&lt;&lt;SENDCHECKSUM&gt;&gt;\n")
  
  md5a = ser.readline()
  print(md5a)
  print(md5b)
  if md5a == md5b:
      print("Correct File Transmission")
  else:
      print("The checksum indicated incorrect file transmission, please check.")
  ser.flush()
  </code></pre>