How to Enable DBMS_CRYPTO in Oracle 11g | ORA-24344 | PLS-00201: identifier 'DBMS_CRYPTO' must be declared

🔹 How to Enable DBMS_CRYPTO in Oracle 11g

The DBMS_CRYPTO package is used for encryption, hashing, and secure data handling in Oracle. However, it requires explicit privileges before use.

[Warning] ORA-24344: success with compilation error
4/26    PLS-00201: identifier 'DBMS_CRYPTO' must be declared
4/5     PL/SQL: Statement ignored
 (1: 0): Warning: compiled but with compilation errors



1️⃣ Grant Required Privileges

By default, DBMS_CRYPTO is not accessible to normal users in Oracle 11g. You need to grant access.

🔹 Step 1: Grant Execution Privileges

Log in as SYSDBA and run:

GRANT EXECUTE ON DBMS_CRYPTO TO your_username;

🔹 Replace your_username with the actual Oracle user who needs access.


2️⃣ Verify DBMS_CRYPTO is Enabled

Check if the package is available:

SELECT * FROM all_objects WHERE object_name = 'DBMS_CRYPTO';

🔹 If it returns a row, the package exists.


3️⃣ Test DBMS_CRYPTO

Run a simple encryption test:

DECLARE
v_encrypted RAW(2000); BEGIN v_encrypted := DBMS_CRYPTO.ENCRYPT( src => UTL_I18N.STRING_TO_RAW('HelloWorld', 'AL32UTF8'), typ => DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5, key => UTL_RAW.CAST_TO_RAW('1234567890123456') ); DBMS_OUTPUT.PUT_LINE(RAWTOHEX(v_encrypted)); END; /

🔹 If this runs without errors, DBMS_CRYPTO is enabled.


4️⃣ Common Errors & Fixes

🔹 ORA-00904: DBMS_CRYPTO.ENCRYPT: Invalid Identifier

Fix: Grant EXECUTE privilege:

GRANT EXECUTE ON DBMS_CRYPTO TO your_username;

🔹 ORA-06550: PLS-00201: Identifier 'DBMS_CRYPTO' must be declared

Fix: Connect as SYSDBA and recompile:

ALTER SESSION SET PLSQL_CCFLAGS = 'ENABLE:TRUE';

✅ Summary

StepCommand
Grant accessGRANT EXECUTE ON DBMS_CRYPTO TO your_username;
Verify packageSELECT * FROM all_objects WHERE object_name = 'DBMS_CRYPTO';
Test encryptionUse DBMS_CRYPTO.ENCRYPT to test


Post a Comment

And that's all there is to it!

If anyone has any other questions or requests for future How To posts, you can either ask them in the comments or email me. Please don't feel shy at all!

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

Previous Post Next Post