Tuesday, June 30, 2015

Wrapping Utility - Part 1

Wrapping is the process of hiding PL/SQL source code. It helps to protect your source code from others who might misuse it :)

Oracle has provided the WRAP utility to encrypt source code for this purpose. The WRAP utility can be invoked on the operating system, like Windows, command line as it comes with the Oracle client. It can also be invoked within the database using DBMS_DDL package (Part 2)

Normally PL/SQL code, such as a package specification, package body, function, procedure, type specification, or type body is wrapped using the wrap utility given by Oracle. 

Note: It does not wrap PL/SQL content in anonymous blocks or triggers or non-PL/SQL code 
This is a command line tool and syntax is:

wrap iname=input_file [oname=output_file]

input_file is the name of the file which is containing your source code, it can be with extension or without extension.

wrap iname=/mydir/myfile
wrap iname=/mydir/myfile.sql

output_file is the name of the wrapped file that is created. The defaults extension of output file  is .plb.

wrap iname=/mydir/myfile 
>  Output file will be myfile.plb

wrap iname=/mydir/myfile oname=/yourdir/yourfile.out


>Test: Create a test function Get_Sysdate and store it with name Get_sysdate.sql in your hard drive

Here, I have stored it in directory: D:\Wrapping Utility




Open Command Prompt > Start - Run – cmd - Enter

Goto the directory where you have stored your source file

cd  D:\Wrap Utility
run below command to wrap the file
wrap iname=Get_Sysdate

It will wrap the source code and create a new file Get_Sysdate with default extension .plb


Open the file, you can see the wrapped code.

Now compile the wrapped file


Now check the source code in DB

  select *
    from all_source
   where name = 'GET_SYSDATE'
     and owner = 'APPS';



Now execute the function

select get_sysdate
  from dual;



No comments:

Post a Comment