Skip Headers

PL/SQL User's Guide and Reference
10g Release 1 (10.1)

Part Number B10807-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

C Obfuscating Source Code with the PL/SQL Wrap Utility

This appendix shows you how to run the wrap utility. wrap is a standalone program that obfuscates PL/SQL source code, so that you can deliver PL/SQL applications without exposing your source code.

This appendix contains these topics:

Advantages of Wrapping PL/SQL Procedures

Running the PL/SQL Wrap Utility

To run the wrap utility, enter the wrap command at your operating system prompt using the following syntax:

wrap iname=input_file [oname=output_file]

Note: Do not use any spaces around the equal signs.

input_file is the name of a file containing SQL statements, that you typically run using SQL*Plus. If you omit the file extension, an extension of .sql is assumed. For example, the following commands are equivalent:

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

You can also specify a different file extension:

wrap iname=/mydir/myfile.src

output_file is the name of the obfuscated file that is created. The oname option is optional, because the output file name defaults to that of the input file and its extension defaults to .plb. For example, the following commands are equivalent:

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

You can use the option oname to specify a different file name and extension:

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

Input and Output Files for the PL/SQL Wrap Utility

The input file can contain any combination of SQL statements. Most statements are passed through unchanged. CREATE statements that define subprograms, packages, or object types are obfuscated; their bodies are replaced by a scrambled form that the PL/SQL compiler understands.

The following CREATE statements are obfuscated:

CREATE [OR REPLACE] FUNCTION function_name
CREATE [OR REPLACE] PROCEDURE procedure_name
CREATE [OR REPLACE] PACKAGE package_name
CREATE [OR REPLACE] PACKAGE BODY package_name
CREATE [OR REPLACE] TYPE type_name AS OBJECT
CREATE [OR REPLACE] TYPE type_name UNDER type_name
CREATE [OR REPLACE] TYPE BODY type_name

Note: The CREATE [OR REPLACE] TRIGGER statement, and BEGIN..END anonymous blocks, are not obfuscated.

All other SQL statements are passed unchanged to the output file. Most comment lines are deleted. C-style comments (delimited by /* */) are preserved when they occur in the middle of a SQL statement. Comments are also preserved when they occur immediately after the CREATE statement, before the obfuscated body starts.

The output file is a text file, which you can run in SQL*Plus to set up your PL/SQL procedures, functions, and packages:

SQL> @wrapped_file_name.plb;

Tips:

  • When wrapping a package or object type, wrap only the body, not the spec. That way, other developers see the information they need to use the package or type, but they do not see its implementation.

  • PL/SQL source inside wrapped files cannot be edited. To change wrapped PL/SQL code, edit the original source file and wrap it again. You can either hold off on wrapping your code until it is ready for shipment to end-users, or include the wrapping operation as part of your build environment.

  • To be sure that all the important parts of your source code are obfuscated, view the wrapped file in a text editor before distributing it.

Limitations of the PL/SQL Wrap Utility