SYS.DBMS_CRYPTO error while decrypting the encrypted password
<p>I have the below function in package where i am trying to decrpyt the encrypted password but getting the below error message:</p>

<pre><code>ORA-28817: PL/SQL function returned an error.
ORA-06512: at "SYS.DBMS_CRYPTO_FFI", 
ORA-06512: at "SYS.DBMS_CRYPTO", 
ORA-06512: at "RATOR_MONITORING_CONFIGURATION.ENCRYPT_DECRYPT_PASSWORD", line 11    
28817. 00000 -  "PL/SQL function returned an error."
*Cause:    A PL/SQL function returned an error unexpectedly.
*Action:   This is an internal error. Enable tracing to find more
           information. Contact Oracle customer support if needed.
*Document: NO
</code></pre>

<p>When i run this package in different server and machine then i am able to execute the package and able to decrypt the password with the same query.</p>

<p>Below is my package:</p>

<pre><code>create or replace PACKAGE BODY "ENCRYPT_DECRYPT_PASSWORD"
AS

  l_key RAW(128) := utl_raw.cast_to_raw('abcdefgh');

 FUNCTION decrypt_val( p_val IN varchar2 ) RETURN VARCHAR2
  IS
    l_decrypted RAW(2048);
    l_val RAW(2048) := utl_raw.cast_to_raw(p_val);
   BEGIN
         l_decrypted := dbms_crypto.decrypt
                ( src =&gt;  l_val,
                  typ =&gt; dbms_crypto.des_cbc_pkcs5,
                  key =&gt; l_key );

         return utl_raw.cast_to_varchar2(l_decrypted);

  END decrypt_val;


FUNCTION get_decrypted_password( table_name IN varchar2,column_name IN varchar2,table_id IN varchar2,table_id_val IN varchar2 ) RETURN VARCHAR2
  IS
     encrypted_pas varchar2(100);
     decrypted_pas varchar2(100);

   BEGIN
      EXECUTE IMMEDIATE 'select ' || column_name || ' from ' || table_name || ' where ' || table_id || ' = ' || table_id_val
         INTO encrypted_pas;
         Select decrypt_val(encrypted_pas) into decrypted_pas from dual;
          return decrypt_val(encrypted_pas);
  END get_decrypted_password;

END encrypt_decrypt_password;
</code></pre>

<p>I also tried giving <code>DBMS_CRYPTO</code> permission to the user and my package has also been compiled but when i tried to run the below command to decrypt the password then i am getting the error.</p>

<pre><code>Select ENCRYPT_DECRYPT_PASSWORD.get_decrypted_password('DB_CONNECTION','PASSWORD','DB_CONNECTION_ID',11) from dual;
</code></pre>