Problem : PLS-00201: identifier ‘DBMS_CRYPTO.ENCRYPT’ must be declared

Problem : PLS-00201: identifier ‘DBMS_CRYPTO.ENCRYPT’ must be declared

Hi I am trying to use dbms_crypto pkg. I am getting below error. can u pls help me what I need to do

SQL>  DECLARE
2   l_credit_card_no VARCHAR2(19) := ‘1234-5678-9012-3456’;
3   l_ccn_raw RAW(128) := utl_raw.cast_to_raw(l_credit_card_no);
4   l_key     RAW(128) := utl_raw.cast_to_raw(‘abcdefgh’);
5
6   l_encrypted_raw RAW(2048);
7   l_decrypted_raw RAW(2048);
8  BEGIN
9    dbms_output.put_line(‘Original : ‘ || l_credit_card_no);
10
11    l_encrypted_raw := dbms_crypto.encrypt(l_ccn_raw,
12    dbms_crypto.des_cbc_pkcs5, l_key);
13
14    dbms_output.put_line(‘Encrypted : ‘ ||
15    RAWTOHEX(utl_raw.cast_to_raw(l_encrypted_raw)));
16
17    l_decrypted_raw := dbms_crypto.decrypt(src => l_encrypted_raw,
18    typ => dbms_crypto.des_cbc_pkcs5, key => l_key);
19
20    dbms_output.put_line(‘Decrypted : ‘ ||
21    utl_raw.cast_to_varchar2(l_decrypted_raw));
22  END;
23  /
l_encrypted_raw := dbms_crypto.encrypt(l_ccn_raw,
*
ERROR at line 11:
ORA-06550: line 11, column 22:
PLS-00201: identifier ‘DBMS_CRYPTO.ENCRYPT’ must be declared
ORA-06550: line 11, column 3:
PL/SQL: Statement ignored
ORA-06550: line 17, column 22:
PLS-00201: identifier ‘DBMS_CRYPTO.DECRYPT’ must be declared
ORA-06550: line 17, column 3:
PL/SQL: Statement ignored

Thanks


Solution : PLS-00201: identifier ‘DBMS_CRYPTO.ENCRYPT’ must be declared

Log in as the owner of DBMS_CRYPTO (it may be SYS) then:
grant execute on dbms_crypto to [your schema name];

Also check if there is a public synonym for dbms_crypto, and if not, create one.