Friday, February 12, 2010

Oracle PL/SQL: MD5 checksum of an PL/SQL object

Oracle PL/SQL: MD5 checksum of an PL/SQL object

Here comes the Code to find the MD5 checksum of an PL/SQL object named VERIFY_FUNCTION.

This DBMS_CRYPTO is available in 10GR2. In 8i and 9i, we may have to call DBMS_OBFUSCATION_TOOLKIT instead..

**************** Code Begins ************************
set serveroutput on size 1000000

declare
hash varchar2(32);
code clob;
begin
for frec in (
select text
from dba_source
where owner = 'SYS'
and type = 'FUNCTION'
and name = 'VERIFY_FUNCTION'
order by line
)
loop
code := code || frec.text;
end loop;
hash := rawtohex(
dbms_crypto.hash (
typ => dbms_crypto.hash_md5,
src => code
)
);

dbms_output.put_line('MD5 HASH of VERIFY_FUNCTION : ' || hash);

end;
/

************** Code Ends **********************

No comments:

Post a Comment