title: Hashed Database Password [Hibernate]
body: <p>Due to security requirements I need to store the Database password as a md5-hash in my hibernate.cfg.xml, but as far as I know Hibernate does not support hashed passwords. I am using hibernate 5.1.0.</p>
  
  <p>My hibernate.cfg.xml looks like this:</p>
  
  <pre><code>    &lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
      &lt;property name="hibernate.connection.driver_class"&gt;org.h2.Driver &lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:h2:tcp://localhost/~/test&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;sa&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;
        &lt;property name="show_sql"&gt;true&lt;/property&gt;
    &lt;property name="hibernate.c3p0.min_size"&gt;5&lt;/property&gt;
    &lt;property name="hibernate.c3p0.max_size"&gt;20&lt;/property&gt;
    &lt;property name="hibernate.c3p0.timeout"&gt;300&lt;/property&gt;
    &lt;property name="hibernate.c3p0.max_statements"&gt;50&lt;/property&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
      &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
  
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>This is how I create a sessionFactory:</p>
  
  <pre><code>import org.hibernate.SessionFactory;
  import org.hibernate.cfg.Configuration;
  
  public class HibernateUtility {
      private static final SessionFactory sessionFactory = buildSessionFactory();
  
      private static SessionFactory buildSessionFactory() {
          try {
              // Create the SessionFactory from hibernate.cfg.xml
              return new Configuration()
                      .configure()
                      .buildSessionFactory().;
          } catch (Throwable ex) {
              System.err.println("Initial SessionFactory creation failed." + ex);
              throw new ExceptionInInitializerError(ex);
          }
      }
  
      public static SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  }
  </code></pre>
  
  <p>Is there a way to use a hashed Database password for hibernate?</p>