Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ult_i18n.string_to_raw

Jagdeep SangwanApr 15 2014 — edited Apr 15 2014

Hi All,

I am trying to use package dbms_crypto for encrypt and decrypt of data. Following is code of my package which i have written:

create or replace package body encdec_crypto

as

  l_num_key_bytes number := 32;

  l_key_bytes raw(32) := dbms_crypto.randombytes(l_num_key_bytes);

  l_type pls_integer := dbms_crypto.encrypt_aes256

  + dbms_crypto.chain_cbc

  + dbms_crypto.pad_pkcs5;

  function encrypt_pwd(

  p_text varchar2

  )

  return raw

  is

  l_encrypted_data raw(2000);

  begin

  l_encrypted_data := dbms_crypto.encrypt(

  src => ult_i18n.string_to_raw(p_text, 'AL32UTF8')

  , typ => l_type

  , key => l_key_bytes

  );

  return l_encrypted_data;

  end encrypt_pwd;

  function decrypt_pwd(

  p_raw raw

  )

  return varchar2

  is

  l_decrypted_data raw(2000);

  begin

  l_decrypted_data := dbms_crypto.decrypt(

  src => p_raw

  , typ => l_type

  , key => l_key_bytes

  );

  return utl_i18n.raw_to_char(l_decrypted_data, 'AL32UTF8');

  end decrypt_pwd;

end encdec_crypto;

/

show err

Initially when i tried to compile this code it gave me error about dbms_crypto package as invalid identifier, then i gave execute command on this procedure to my user from sys, thereafter it is showing me following error about utl_i18n.string_to_raw function

Warning: Package Body created with compilation errors.

Errors for PACKAGE BODY ENCDEC_CRYPTO:

LINE/COL ERROR

-------- -----------------------------------------------------------------

16/3     PL/SQL: Statement ignored

17/13    PLS-00201: identifier 'ULT_I18N.STRING_TO_RAW' must be declared

jagdeep@css>

I have given the execute permission for this package also to this user as following:

SQL> grant execute on dbms_crypto to jagdeep;

Grant succeeded.

SQL> grant execute on utl_i18n to jagdeep;

Grant succeeded.

Kindly assist me on this, what i am missing in here

Regards

Jagdeep Sangwan

My version is

BANNER

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi

PL/SQL Release 10.2.0.1.0 - Production

CORE    10.2.0.1.0      Production

TNS for Linux: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

This post has been answered by Karthick2003 on Apr 15 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2014
Added on Apr 15 2014
3 comments
814 views