How can I encrypt/decrypt data in Forms using a specified Package?
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???