title: Select DBMS_CRYPTO password hashes in Oracle 11g
body: <p>I am currently hashing my password field in my Oracle database by using <code>DBMS_CRYPTO.HASH</code>. At this point, however, I need to allow my Java application to be able to authenticate a password on user input in a way similar to what MySQL does. Something like:</p>
  
  <pre><code>SELECT *
  FROM user_login_table
  WHERE password = SHA1('MyPassword');
  </code></pre>
  
  <p>I am currently hashing via the following procedure:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE 
    MUNGAI.p_auth_insert_user (
      par_username in varchar2,
      par_password in varchar2,
      par_work in varchar2
    )
  IS l_hash raw(2000);
    BEGIN
      l_hash :=
        dbms_crypto.hash(
          utl_i18n.string_to_raw(par_password || par_work || upper(par_username),
          'AL32UTF8'
        ),
        dbms_crypto.hash_sh1
      );
  
      INSERT INTO user_login_table (user_name, p_word, work_class)
      VALUES (par_username, l_hash, par_work);
    END p_auth_insert_user;
  /
  </code></pre>
  
  <p>I am then executing the procedure as follows, to insert into the table:</p>
  
  <pre><code>EXEC MUNGAI.p_auth_insert_user('MUNGAI', 'gatungo', '999')
  </code></pre>
  
  <p>Is there a better way to achieve this in my situation? I am using Oracle 11g, if that matters.</p>