title: Create two different binaries with same size and same md5 hash
body: <p>I have two different files: <code>code1.c</code> and <code>code2.c</code>, both of them already contain some <em>C code</em> (files contents differ).</p>
  
  <p>I would like to compile both files preferably with the same compilation flags so I will end up with two binaries which would have <em>same size</em> and <em>same md5 hash</em>.</p>
  
  <p><strong>Note:</strong> It is allowed to add extra dead/junk code to one of the files. I think <code>gcc</code> compiler version should not matter? (I would use <code>gcc version ≥ 7</code>)</p>
  
  <p>How can I achieve that?</p>
  
  <hr>
  
  <p>I found some articles which show that md5 hash collision is possible, but the problem is that it should result in the same file size:</p>
  
  <ul>
  <li><a href="https://crypto.stackexchange.com/questions/1434/are-there-two-known-strings-which-have-the-same-md5-hash-value">https://crypto.stackexchange.com/questions/1434/are-there-two-known-strings-which-have-the-same-md5-hash-value</a></li>
  <li><a href="https://natmchugh.blogspot.com/2015/05/how-to-make-two-binaries-with-same-md5.html" rel="nofollow noreferrer">https://natmchugh.blogspot.com/2015/05/how-to-make-two-binaries-with-same-md5.html</a></li>
  <li><a href="https://stackoverflow.com/questions/1756004/can-two-different-strings-generate-the-same-md5-hash-code">Can two different strings generate the same MD5 hash code?</a></li>
  </ul>