title: Difference between BINARY(16) and CHAR(32) when storing MD5 in database
body: <p>Based on various recommendations such as <a href="https://stackoverflow.com/questions/247304/mysql-what-data-type-to-use-for-hashed-password-field-and-what-length">What data type to use for hashed password field and what length?</a>, I could store md5 as either CHAR(32) or BINARY(16).  But when I do so using BINARY(16), the stored value is identical to the first 16 characters of the CHAR(32) stored results as well as the first 16 characters of the <code>SELECT MD5()</code> results.  What are the significance of the later 16 characters, and is their lack of presence in the binary column resulting in lost data?</p>
  
  <pre><code>CREATE  TABLE test (id INT NOT NULL AUTO_INCREMENT, value VARCHAR(6), md5_char CHAR(32) NOT NULL, md5_binary BINARY(16) NOT NULL, PRIMARY KEY (id)) ENGINE = InnoDB;
  INSERT INTO test(value,md5_char,md5_binary) VALUES("one!",md5("one!"),md5("one!"));
  INSERT INTO test(value,md5_char,md5_binary) VALUES("two%",md5("two%"),md5("two%"));
  INSERT INTO test(value,md5_char,md5_binary) VALUES("three~",md5("three~"),md5("three~"));
  SELECT value,md5(value),md5_char,md5_binary FROM test;
  DROP TABLE test;
  
  +--------+----------------------------------+----------------------------------+------------------+
  | value  | md5(value)                       | md5_char                         | md5_binary       |
  +--------+----------------------------------+----------------------------------+------------------+
  | one!   | 633c8403325f1cf963809e6eb224d77e | 633c8403325f1cf963809e6eb224d77e | 633c8403325f1cf9 |
  | two%   | 48bbec047b4451a2018e0f652807b7d0 | 48bbec047b4451a2018e0f652807b7d0 | 48bbec047b4451a2 |
  | three~ | fee453bb4eb68dcdfee07575e75c8cc5 | fee453bb4eb68dcdfee07575e75c8cc5 | fee453bb4eb68dcd |
  +--------+----------------------------------+----------------------------------+------------------+
  </code></pre>