Skip to content

Instantly share code, notes, and snippets.

@KrashLeviathan
Created March 26, 2021 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KrashLeviathan/5ae3132d26e7cd29b0333fa7d5df617b to your computer and use it in GitHub Desktop.
Save KrashLeviathan/5ae3132d26e7cd29b0333fa7d5df617b to your computer and use it in GitHub Desktop.
EXAMPLE: Wrapping (obfuscating) a PL/SQL package body
-- Documentation: https://docs.oracle.com/en/database/oracle/oracle-database/18/lnpls/plsql-source-text-wrapping.html
-- One thing to keep in mind (that I didn't find in the docs) is that later, if you want to
-- update the variables in the package spec and re-compile the spec and the wrapped body, you can do
-- that in SQL Developer without having to re-wrap the original source code. Just open up
-- the wrapped body and click the Compile button.
-- Create package specification without obfuscation
create or replace PACKAGE HELLO_PKG AS
g_person_to_greet varchar2(8) := 'Nate';
procedure hello;
END HELLO_PKG;
-- Using the DBMS_DDL package is one way to wrap the body.
-- There's also command line utilities.
DECLARE
l_str VARCHAR2(32000);
BEGIN
l_str := q'~
CREATE OR REPLACE
PACKAGE BODY HELLO_PKG AS
procedure hello AS
BEGIN
dbms_output.put_line('Hello ' || g_person_to_greet || '!');
END hello;
END HELLO_PKG;~';
dbms_ddl.create_wrapped(l_str);
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment