Oracle: How to call an overloaded procedure?

How to call DBMS_OBFUSCATION_TOOLKIT.DESEncrypt? (without using PL / SQL, if possible)

select DBMS_OBFUSCATION_TOOLKIT.DESEncrypt('x','y') from dual;

does not work because DESEncrypt is overloaded:

ORA-06553: PLS-307: Too many declarations of "DESENCRYPT" match this call
06553. 00000 -  "PLS-%s: %s"
*Cause:    
*Action:

Is there a way to choose one implementation of DESENCRYPT (possibly a variant of VARCHAR2) to avoid this error?

+3
source share
3 answers

here you go, just let me know what kind of overload is used by specifying the parameter names!

select DBMS_OBFUSCATION_TOOLKIT.DesEncrypt(INPUT_STRING=>'11112abc',KEY_STRING=>'4578ccde') 
from dual ;

returns

M5w5z

Note that your key must be at least 8 bytes:

ORA-28234: ORA-06512: "SYS.DBMS_OBFUSCATION_TOOLKIT_FFI", 21 ORA-06512: "SYS.DBMS_OBFUSCATION_TOOLKIT", 126 28234. 00000 - " " * . . DES             8 . Triple DES             16 24            . * : .


( )

create or replace
function DesEncrypt(pinputString IN VARCHAR2 , pKeyString in VARCHAR2) RETURN varchar2
IS
BEGIN
return DBMS_OBFUSCATION_TOOLKIT.DesEncrypt(INPUT_STRING=>INPUTSTRING,KEY_STRING=>KEYSTRING);
END DesEncrypt;
/
select DesEncrypt('11112abc' , '4578ccde') from dual ;

10g, DBMS_CRYPTO http://www.stanford.edu/dept/itss/docs/oracle/10g/network.101/b10773/apdvncrp.htm

+7

Oracle 11G :

select DBMS_OBFUSCATION_TOOLKIT.DESEncrypt(input_string=>'x',key_string=>'y')
from dual;

, Oracle, - .

+9

here is crypt / decrypt using the older dbms_obfuscation_toolkit:

create or replace function crypt(p_str in varchar2, p_key in varchar2) return varchar2
as
  l_data varchar2(255);
begin
  l_data := rpad(p_str, (trunc(length(p_str)/8)+1)*8,chr(0));
  dbms_obfuscation_toolkit.DESEncrypt
  (input_string=>l_data,
  key_string=>p_key,
  encrypted_string=>l_data);

  return l_data;
end;

And for decryption:

create or replace function decrypt(p_str in varchar2, p_key in varchar2) return varchar2
as
  l_data varchar2(255);
begin
  dbms_obfuscation_tookit.DESDecrypt
  (input_string=>p_str,
  key_string=>p_key,
  decrypted_string=>l_data);

  return rtrim(l_data,chr(0));
end;

And use:

declare

  l_data varchar2(100);
  l_key varchar2(100);
  l_encrypted varchar2(100);
  l_decrypted varchar2(100);

begin
  l_data := 'This is secret!!!';
  l_key := 'My secret key';
  dbms_output.put_line(l_data);

  l_encrypted := crypt(l_data, l_key);
  dbms_output.put_line(l_encrypted);

  l_decrypted := decrypt(l_encrypted, l_key);
  dbms_output.put_line(l_decrypted);

end;
+2
source

All Articles