8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Misc » Here

Comments for Data Encryption - DBMS_OBFUSCATION_TOOLKIT


Laurent said...

8iR3 also contain DES3

Pete said...

This is great. Is there a way to keep the data type in Varchar2 and encrypt that. Why do we need a Raw data type to do this.
Pete

Tim... said...

Hi.

The output from the encryption functions is RAW. You can cast the output to VARCHAR2 using "UTL_RAW.cast_to_varchar2".

Cheers

Tim...

PS. Please ask questions in the forum :)

shri said...

Its good example

James said...

You don't handle attempts to decrypt data that isn't a multiple of 8 chars long. So decrypt('HI') gets ORA-28232.

Tim... said...

Hi.

1) You can't decrypt something that is not decrypted.
2) When encrypt something, it pads it to a multiple of 8 bytes before encrypting it. As such, it can be decrypted successfully.

If you had used the code as described you would know this.

Cheers

Tim...

vttvolant said...

i have modify the code source and it's good

CREATE OR REPLACE PACKAGE PAC_BOSS AS

g_WC_RAW_key RAW(128) := UTL_RAW.cast_to_raw('12345678');
g_WC_char_completion VARCHAR2(1) := '~';

PROCEDURE PRO_COMPLETION_PWD (PC_PWD IN OUT VARCHAR2);

FUNCTION fun_cryptage (PC_PWD IN VARCHAR2) RETURN RAW;

FUNCTION fun_decryptage (PC_RAW_PWD_CRYPT IN RAW) RETURN VARCHAR2;



END PAC_BOSS;
/


CREATE OR REPLACE PACKAGE BODY PAC_BOSS AS




-- --------------------------------------------------
FUNCTION fun_cryptage (PC_PWD IN VARCHAR2) RETURN RAW IS
-- --------------------------------------------------
WC_PWD VARCHAR2(16) := PC_PWD;
WC_RAW_PWD RAW(128) ;
WC_RAW_PWD_CRYPT RAW(2048) ;

BEGIN
PRO_COMPLETION_PWD(WC_PWD);
WC_RAW_PWD := UTL_RAW.cast_to_raw(WC_PWD);
DBMS_OBFUSCATION_TOOLKIT.desencrypt(input => WC_RAW_PWD,
key => g_WC_RAW_key,
encrypted_data => WC_RAW_PWD_CRYPT);



RETURN WC_RAW_PWD_CRYPT;
END;
-- --------------------------------------------------



-- --------------------------------------------------
FUNCTION fun_decryptage (PC_RAW_PWD_CRYPT IN RAW) RETURN VARCHAR2 IS
-- --------------------------------------------------
WC_RAW_PWD_CRYPT RAW(2048) := PC_RAW_PWD_CRYPT;
-- WC_RAW_PWD RAW(128) := UTL_RAW.cast_to_raw(WC_PWD);
WC_RAW_PWD_DECRYPT RAW(2048) ;
-- WC_DECRYPT_PWD VARCHAR2(32767);
BEGIN
DBMS_OBFUSCATION_TOOLKIT.desdecrypt(input => WC_RAW_PWD_CRYPT,
key => g_WC_RAW_key,
decrypted_data => WC_RAW_PWD_DECRYPT);

--supprime caractere de completion --
RETURN RTrim(UTL_RAW.cast_to_varchar2(WC_RAW_PWD_DECRYPT), g_WC_char_completion);
END;
-- --------------------------------------------------


-- --------------------------------------------------
PROCEDURE PRO_COMPLETION_PWD (PC_PWD IN OUT VARCHAR2) IS
-- la clé doit etre d'une longueur multiple de 8 --
-- --------------------------------------------------
PN_UNIT NUMBER;
BEGIN
-- IF LENGTH(PC_PWD) MOD 8 > 0 THEN
IF MOD( LENGTH(PC_PWD), 8) > 0 THEN
PN_UNIT := TRUNC(LENGTH(PC_PWD)/8) + 1;
PC_PWD := RPAD(PC_PWD, PN_UNIT * 8, g_WC_char_completion);
END IF;
END;
-- --------------------------------------------------

END PAC_BOSS;
/



Don P said...

The Encryption Wizard for Oracle automates the use of DBMS_Crypto and AES encryption with an easy-to-use interface and advanced secure key management features:

Free trial downloads are available at:

www.releationalwizards.com

Naveen said...

Hi....
while I'm giving the following "~"special character this decryption is not working .....

DO NOT ask technical questions here! They will be deleted!

These comments should relate to the contents of a specific article. Constructive criticism is good. Advertising and offensive comments are bad and will be deleted!

If you post personal information (name, email address etc.) you are agreeing to them being stored and displayed. Feel free to remain anonymous.