PLS-00201: identifier 'DBMS_OBFUSCATION_TOOLKIT.DESENCRYPT' must be declared

1.7k Views Asked by At

Here is my package code:

create or replace package body encryption as
    key_string   varchar2(64) := '$0@!H&^%#8I^~!JYE&#$55JKH*(@#$^^';
    encrypted_string varchar2(2048);
    decrypted_string varchar2(2048);

function encrypt (input_string IN varchar2) return varchar2 is
   BEGIN
       encrypted_string :=null;   

       dbms_obfuscation_toolkit.DESEncrypt(input_string =>pad(input_string),
                                       key_string   => key_string,
                                       encrypted_string=> encrypted_string);
       RETURN encrypted_string;                                    
   END;
   
function decrypt(input_string In varchar2) RETURN varchar2 IS
    BEGIN
        decrypted_string :=null;
        encrypted_string :=null; 

        dbms_obfuscation_toolkit.DESDecrypt(input_string => UTL_RAW.cast_to_varchar2(input_string),
                          key_string   =>key_string,
                                          decrypted_string=>decrypted_string);
    
        RETURN RTRIM(decrypted_string,'*');                                   
    END;
END;

After running this I am getting the following error in Oracle 21c but in Oracle 18c it is running successfully.

Compilation failed,line 13 (17:55:27)
PLS-00201: identifier 'DBMS_OBFUSCATION_TOOLKIT.DESENCRYPT' must be declaredCompilation failed,line 13 (17:55:27)
PL/SQL: Statement ignoredCompilation failed,line 26 (17:55:27)
PLS-00201: identifier 'DBMS_OBFUSCATION_TOOLKIT.DESDECRYPT' must be declaredCompilation failed,line 26 (17:55:27)
PL/SQL: Statement ignored 
2

There are 2 best solutions below

0
Littlefoot On

Looks like privileged user (such as SYS, if you don't have any other) should

grant execute on DBMS_OBFUSCATION_TOOLKIT to your_user;
0
xorbator On

It is the DBMS_OBFUSCATION_TOOLKIT that is outright absent from Oracle 21 ... DBMS absent