How to encrypt data elements using plsql?

Posted by Jay     9 September, 2008    530 views   

I am not the original creator of this plsql procedure. Just used this script three years before, and stored at my local computer. Unable to locate the source website. Hence, sharing it with you. The copyright and credit goes to the Author.

DECLARE
–===========================================================================
– Copywright 2007, chet west
–=============================================================================
– DESCRIPTION
–    Example on how to encrypt data elements
–=============================================================================
– MODIFICATION HISTORY
– Person      Date       Comments
– ———   ———- ——————————————–
– Chet        2007       Initial Creation
–=============================================================================

–   input_string                  VARCHAR2 ( 16 ) := ‘tigertigertigert’;
   input_string                  CHAR ( 16 ) := ‘123456789′;
   key_string                    VARCHAR2 ( 16 ) := ‘0racle9i0racle9i’;
   encrypted_string              VARCHAR2 ( 2048 );
   decrypted_string              VARCHAR2 ( 2048 );
   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 ***’;
– 1. Test string data encryption and decryption
– The interface for encrypting raw data is similar.
BEGIN
   Dbms_output.put_line ( ‘> ========= BEGIN TEST =========’ );
   Dbms_output.put_line ( ‘> Input String :’ input_string );
   Dbms_obfuscation_toolkit.DES3Encrypt ( input_string => input_string
                                        ,key_string => key_string
                                        ,encrypted_string => encrypted_string
                                       );
   Dbms_output.put_line ( ‘> encrypted string : ‘ encrypted_string );
   Dbms_obfuscation_toolkit.DES3Decrypt ( input_string => encrypted_string
                                        ,key_string => key_string
                                        ,decrypted_string => decrypted_string
                                       );
   Dbms_output.put_line ( ‘> Decrypted output : ‘ decrypted_string );
   Dbms_output.put_line ( ‘> ‘ );

   IF input_string = decrypted_string THEN
      Dbms_output.put_line ( ‘> DES Encryption and Decryption successful’ );
   END IF;
EXCEPTION
   WHEN error_in_input_buffer_length THEN
      Dbms_output.put_line ( ‘> ‘ INPUT_BUFFER_LENGTH_ERR_MSG );
END;

Post to Twitter  Post to Delicious  Post to Digg    Post to StumbleUpon

Categories : Scripts Oracle Tags : , ,

Comments
July 28, 2009

Excellent site. It was pleasant to me.

Posted by electromozzo
July 29, 2009

I wanted to ask, is there any chance for a modified version of the directory listing script, with an iphone-stylish like design?
http://www.jiltin.com – cool!!!!

Posted by MishaPowerauto
August 6, 2009

I bookmarked this link. Thank you for good job!

Posted by Sdanektir
August 7, 2009

Interesting site, but much advertisments on him. Shall read as subscription, rss.

Posted by Vivalkakira
August 8, 2009

Hello. I think the article is really interesting. I am even interested in reading more. How soon will you update your blog?

Posted by VitalikGromovss
August 8, 2009

Any one can register and post their articles (not advertisement!). They must comply the copyright rules and other government rules.

Posted by Jiltin
Leave a comment

(required)

(required)