Home oracle Cannot use DBMS_CRYPTO

Cannot use DBMS_CRYPTO

Author

Date

Category

Trying to use the DBMS_CRYPTO features. From System Run:

declare
    L_KEY VARCHAR2 (2000): = '1234567890123456';
    L_IN_VAL VARCHAR2 (2000): = 'Confidential Data';
    L_MOD Number
      : = Dbms_crypto.encrypt_aes128.
       + DBMS_CRYPTO.CHAIN_CBC.
       + Dbms_crypto.pad_pkcs5;
    L_ENC RAW (2000);
  Begin.
    L_ENC: =.
     Dbms_crypto.encrypt (utl_i18n.string_to_raw (l_in_val, 'al32utf8'),
                L_MOD,
                utl_i18n.string_to_raw (L_KEY, 'AL32UTF8')
               );
    Dbms_output.put_line ('encrypted =' || l_enc);
  End;

it gives:

error report -
ORA-06550: Row 5, column 17:
PLS-00201: The 'DBMS_CRYPTO' identifier must be announced
ORA-06550: Row 4, column 20:
PL / SQL: Item IGNORED
ORA-06550: Row 11, column 11:
PLS-00201: The 'DBMS_CRYPTO' identifier must be announced
ORA-06550: Row 10, column 8:
PL / SQL: Statement Ignored
06550. 00000 - "Line% S, Column% S: \ N% s"
* Cause: USUALY A PL / SQL COMPILATION ERROR.

Watching Select * from dba_Objects where object_name = 'dbms_crypto'; issues:

tried to create a new user and give him rights:

Grant Execute on sys.dbms_crypto to vice_sys;

But also an error:

Error Starting at Line: 1 in Command -
GRANT EXECUTE ON SYS.DBMS_CRYPTO TO VICE_SYS
ERROR REPORT -
ORA-00942: Table or user view does not exist
00942. 00000 - "Table OR View Does Not Exist"
* Cause:

What to do?


Answer 1, Authority 100%

We must give the right to execute the package. It can only user SYS , no one else.

DBMS_CRYPTO Security Model
Oracle Database Installs This Package In The Sys Schema. You can then Grant Package Access to Existing Users and Roles As Needed.

sql & gt; Show User.
User IS "ME"
SQL & GT; Exec DBMS_OUTPUT.Put_Line ('result =' || dbms_crypto.randombytes (16));
ORA-06550: LINE 1, COLUMN 40:
PLS-00201: IDENTFIER 'DBMS_CRYPTO' MUST BE DECLARED
SQL & GT; Conn SYS / PASS @ DBSRV / PDB1 AS SYSDBA
Connected.
SQL & GT; GRANT EXECUTE ON DBMS_CRYPTO TO ME;
Grant succeeded.
SQL & GT; Conn me/me@MPSRV/pdb1.19c.
Connected.
SQL & GT; Exec DBMS_OUTPUT.Put_Line ('result =' || dbms_crypto.randombytes (16));
Result = 7311CFC8CF6AEB02C5B6238DFB8FBB1E.
PL / SQL Procedure SuccessFully Completed.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions