Oracle 9i之前,提供了一个命令’warp’来加密代码。但它是命令行方式的,是针对脚本的。10g中,Oracle包DBMS_DDL提供了一个新的函数CREATE_WRAPPED来实现对代码的混淆。举例:
SQL> declare
2 V_PROTEX varchar2(2000):='
3 CREATE OR REPLACE PROCEDURE
P_WRAPTEST
4 IS
5 v_count number;
6 BEGIN
7 select count(*) into
v_count from user_tables;
8
DBMS_OUTPUT.PUT_LINE(''Tables number is: '' || v_count);
9 END;
10 ';
11 begin
12
SYS.DBMS_DDL.CREATE_WRAPPED(V_PROTEX);
13 end;
14 /
PL/SQL procedure successfully
completed
再看混淆后的代码:
SQL> SELECT text FROM
USER_SOURCE WHERE name = 'P_WRAPTEST';
TEXT
--------------------------------------------------------------------------------
PROCEDURE P_WRAPTEST wrapped
a000000
367
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
7
a0 db
p9j84ore7Zt5Hy6AyFLId/b/8yMwgwBf2ssVfC+iJhAYzfFpuKZxlTM5k5uuM9GJb/cJyvtE
80zL0AI2lSFOiy6XzIzuX8j8bND0S8hL6aZuCkp25+ESApOeAkn9ow9QaxvOFT8kqbKOtYY+
gChxfOqrjWpmE3CJliplbOiEDDLfcJqzMryW1Xqa0EJCr3kA5lsFM9qrGt1wGrQQpg5d1Y8=