Skip to Main Content

Oracle Forms

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!

How can I encrypt/decrypt data in Forms using a specified Package?

Dev. MusbahNov 8 2009 — edited Nov 24 2009
Hi All,
I have searched in the Internet for ecnrypting/decrypting data in Forms.
That is when I want to query the data outside the Form Application it will be encypted, otherwise if I want to query it in the form application it will be dycrypted

I found this package:

CREATE OR REPLACE PACKAGE Encrypt_pkg AS

FUNCTION encrypt (p_text IN VARCHAR2) RETURN RAW;

FUNCTION decrypt (p_raw IN RAW) RETURN VARCHAR2;

END Encrypt_pkg;
/


CREATE OR REPLACE PACKAGE BODY Encrypt_pkg AS
-- All VARCHAR2 inputs are padded to multiples of 8 charaters,
-- with the encryption key also being a multiple of 8 charaters.
-- The encryption key and padding characters can be altered to suit.

g_key RAW(32767) := UTL_RAW.cast_to_raw('12345678');
g_pad_chr VARCHAR2(1) := '';

PROCEDURE padstring (p_text IN OUT VARCHAR2);


-- --------------------------------------------------
FUNCTION encrypt (p_text IN VARCHAR2) RETURN RAW IS
-- --------------------------------------------------
l_text VARCHAR2(32767) := p_text;
l_encrypted RAW(32767);
BEGIN
padstring(l_text);
DBMS_OBFUSCATION_TOOLKIT.desencrypt(input => UTL_RAW.cast_to_raw(l_text),
key => g_key,
encrypted_data => l_encrypted);
RETURN l_encrypted;
END;
-- --------------------------------------------------



-- --------------------------------------------------
FUNCTION decrypt (p_raw IN RAW) RETURN VARCHAR2 IS
-- --------------------------------------------------
l_decrypted VARCHAR2(32767);
BEGIN
DBMS_OBFUSCATION_TOOLKIT.desdecrypt(input => p_raw,
key => g_key,
decrypted_data => l_decrypted);

RETURN RTrim(UTL_RAW.cast_to_varchar2(l_decrypted), g_pad_chr);
END;
-- --------------------------------------------------


-- --------------------------------------------------
PROCEDURE padstring (p_text IN OUT VARCHAR2) IS
-- --------------------------------------------------
l_units NUMBER;
BEGIN
IF LENGTH(p_text) MOD 8 > 0 THEN
l_units := TRUNC(LENGTH(p_text)/8) + 1;
p_text := RPAD(p_text, l_units * 8, g_pad_chr);
END IF;
END;
-- --------------------------------------------------

END Encrypt_pkg;
-------------------------------------------------------------------------------------------------------------------



** Now How can I use this package to encrypt/decrypt data in the form as I said Plz???
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 22 2009
Added on Nov 8 2009
10 comments
3,130 views