Differences between Oracle hash and tomcat md5?

when using oracle forms to generate the md5 hash, I get a result different from the result given by tomcat.

when using tomcat digest, I get:

C:\apache-tomcat-6.0.26\bin>digest -a md5 mypass
mypass:a029d0df84eb5549c641e04a9ef389e5

using oracle forms i get:

a029d0dfbfeb5549c641e04abff3bfe5

this is the code:

Declare
    v_checksum varchar2( 32 );
    v_hex_value varchar2( 32 );
begin
    v_checksum := SYS.DBMS_OBFUSCATION_TOOLKIT.MD5( input_string => 'mypass' );


    SELECT  LOWER( RAWTOHEX( v_checksum ) ) 
    INTO    v_hex_value
    FROM    dual;

    :res := v_hex_value;
end; 

why don't they give the same result? Is there something wrong with my code?

+3
source share
2 answers

which version of Oracle are you using? Your code gives a good answer to 10.2.0.3.0:

SQL> VARIABLE res VARCHAR2(32);
SQL> Declare
  2      v_checksum varchar2( 32 );
  3      v_hex_value varchar2( 32 );
  4  begin
  5      v_checksum:=SYS.DBMS_OBFUSCATION_TOOLKIT.MD5(input_string=>'mypass');
  6  
  7  
  8      SELECT  LOWER( RAWTOHEX( v_checksum ) )
  9      INTO    v_hex_value
 10      FROM    dual;
 11  
 12      :res := v_hex_value;
 13  end;
 14  /

PL/SQL procedure successfully completed
res
---------
a029d0df84eb5549c641e04a9ef389e5

I also tried other functions MD5and they give the same answer:

SQL> DECLARE
  2     l_input RAW(16) := utl_raw.cast_to_raw('mypass');
  3  BEGIN
  4     :res:=lower(rawtohex(dbms_obfuscation_toolkit.md5(input=>l_input)));
  5  END;
  6  /

PL/SQL procedure successfully completed
res
---------
a029d0df84eb5549c641e04a9ef389e5
+2
source

Your code seems correct

a029d0df84eb5549c641e04a9ef389e5 http://md5hashgenerator.com/index.php

sql-

SELECT CONVERT(VARCHAR(32),HashBytes('MD5', 'mypass'),2)
0

Source: https://habr.com/ru/post/1761708/


All Articles