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!

ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error

718029Dec 14 2009 — edited Dec 16 2009
Hello Gurus,

i am trying to encrypt by the method of dbms_obfuscation_toolkit

CREATE OR REPLACE function Cryption2(input_string in long) return raw
IS
--input_string VARCHAR2(16) := 'tigertigertigert';
message raw(32767);
raw_input RAW(128);
key_string long(20000) := 'scottsco';
raw_key RAW(128);
encrypted_raw RAW(2048);
encrypted_string long(20000);
decrypted_raw RAW(2048);
decrypted_string long(20000);
error_in_input_buffer_length EXCEPTION;
PRAGMA EXCEPTION_INIT(error_in_input_buffer_length, -28232);
INPUT_BUFFER_LENGTH_ERR_MSG VARCHAR2(100) :=
'*** DES INPUT BUFFER NOT A MULTIPLE OF 8 BYTES ***';
BEGIN
message:=UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
message:=UTL_RAW.CAST_TO_RAW(CONVERT(key_string,'AL32UTF8','US7ASCII'));
dbms_output.put_line('> ========= BEGIN TEST =========');
dbms_output.put_line('> Input string : ' ||
input_string);
BEGIN < ignore this, typo in Oracle's documentation
dbms_obfuscation_toolkit.DESEncrypt(
input_string => input_string,
key_string => key_string,
encrypted_string => encrypted_string );
dbms_output.put_line('> Encrypted string : ' ||
encrypted_string);
--Add DESDecrypt as shown, change raw to key_string
--END IF;
return encrypted_string ;
EXCEPTION
WHEN error_in_input_buffer_length THEN
dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG);
END;
/

But i am getting the following error

when i try :- select cryption2('abcdefgh') from dual;

ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
ORA-06512: at " ", line 31

Thanks & Regards
Pratik Lakhpatwala
Jr Oracle DBA

Edited by: Pratik.L on Dec 13, 2009 9:58 PM
This post has been answered by Twinkle on Dec 16 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 13 2010
Added on Dec 14 2009
22 comments
19,765 views