Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dbms_crypto.hash returns a different hash frequently after upgrade to APEX 24.1

APEX-DevNov 5 2024

Hello Experts,

We running into a string issue. We have a function in a package to encrypt the clob to sh256 hash :

function get_hash(p_text clob)    
    return varchar2    
as    
    v_sha256 varchar2(128);  
begin
   v_sha256 := dbms_crypto.hash (    
        p_text,    
        dbms_crypto.hash_sh256    
    );   
    
    return v_sha256;    
end get_hash;

The problem is when calling this function sometimes it returns a wrong hash. The function returns this hash frequently :

E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855

When we were on APEX 20.2 it works fine. I tried using static value for clob in SQL Command and it works :

declare
   v_clob clob := '<long xml text>';
begin
   htp.p(test_pkg.get_hash(v_clob));
end;

But when calling this function from the package it returns the above hash sometimes. I tried also calling this function from SQL PLUS and it works unlike Oracle APEX applications. The clob is an XML text that we generate it using another function. This is from SQL Command :

declare
	v_clob clob := test_pkg.generate_xml_clob(p_id => 1000);
begin
	htp.p(test_pkg.get_hash(v_clob));
end;
E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855

Statement processed.
0.48 seconds

Any help ?
Thank you.

Comments
Post Details
Added on Nov 5 2024
10 comments
354 views