Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: [8.1.7] Anyone using the DBMS_OBFUSCATION_TOOLKIT.MD5 function ?
In article <9tb1sd$1cje6$1_at_ID-18487.news.dfncis.de>, davide_at_yahoo.com says...
>
>
>I have to use the DBMS_OBFUSCATION_TOOLKIT.MD5 function to crypt a
>password that I receive from another system, there are some problems
>thought. The first one is that the MD5 family of functions aren't
>described in the documentation, the second (much more important) is
>that anytime I try to use it, it complains that the function to use
>is not clear.
>
>This is my "bridge" function :
>
>create or replace function crypt(instring varchar2)
>return varchar2 as
> tmpstring varchar2(32);
>begin
> tmpstring := substr(instring,1,32);
> tmpstring := dbms_obfuscation_toolkit.md5(tmpstring);
> return substr(rawtohex(tmpstring),1,32);
>
>end crypt;
>
>trying to compile this function I obtain:
>
>SQL> show err;
>Errors for FUNCTION CRYPT:
>
>LINE/COL ERROR
>-------- -----------------------------------------------------------------
>6/2 PL/SQL: Statement ignored
>6/15 PLS-00307: too many declarations of 'MD5' match this call
>SQL>
>
>Anyone have some hints ?
>
>Davide
>
since they overloaded (unfortunately) the MD5 routine on RAW and VARCHAR2 types -- we need to use the parameter name to distiguish between the two.
Couple of comments
o I wouldn't call it "crypt", its a digest. crypt implies decrypt and its not decryptable. its a one way digest
o i wouldn't substr the input string - you'll want to use the entire string. You'll want to send in the user/password together so that different people using the SAME password get different digests. You might even through a "magic salt" in there (extra string).
o you do not need to substr the return result. The digest is always a varchar2(16)
Here is an example:
ops$tkyte_at_ORA817DEV.US.ORACLE.COM> create or replace function DIGEST( p_string
in varchar2 ) return varchar2
2 as
3 begin
4 return dbms_obfuscation_toolkit.md5( input_string => p_string );
5 end;
6 /
Function created.
ops$tkyte_at_ORA817DEV.US.ORACLE.COM> column digest format a16 ops$tkyte_at_ORA817DEV.US.ORACLE.COM> ops$tkyte_at_ORA817DEV.US.ORACLE.COM> select 'TIGER', digest( 'SCOTT/TIGER' )digest from dual;
'TIGE DIGEST
----- ----------------
1 row selected.
ops$tkyte_at_ORA817DEV.US.ORACLE.COM> select 'TIGER', digest( 'TKYTE/TIGER' ) digest from dual;
'TIGE DIGEST
----- ----------------
1 row selected.
-- Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Mon Nov 19 2001 - 08:22:29 CST
![]() |
![]() |