热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

OraclePL/SQL代码加解密

Oracle10gPLSQL的wrap过程是对源码先进行lz压缩lzstr,然后对压缩数据进行SHA-1运算得到40位的加密串shstr,然后将加密串与压

Oracle 10g PL/SQL的wrap过程是对源码先进行lz压缩lzstr,然后对压缩数据进行SHA-1运算得到40位的加密串shstr,然后将加密串与压

通过Oracle的PL/SQL代码加密来保护业务逻辑在有些场合非常有用,,简单整理了下:

一. 通过Wrap命令来加密

1. 创建一个例子文件pro_wrap.sql

create or replace procedure pro_wrap is
begin
dbms_output.put_line('Wrap Demo');
end pro_wrap;

2. 通过wrap命令来生成pld加密文件

wrap iname=c:\pk\pro_wrap.sql Oname=c:\pk\pro_wrap.plb

c:\pk>wrap iname=c:\pk\pro_wrap.sql Oname=c:\pk\pro_wrap.plb

PL/SQL Wrapper: Release 11.2.0.1.0- 64bit Production on 星期二 3月 25 21:58:20 2014

Copyright (c) 1993, 2009, Oracle. All rights reserved.

Processing c:\pk\pro_wrap.sql to c:\pk\pro_wrap.plb

3.通过加密出来的文件pro_wrap.pld,生成存储过程

c:\pk>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期二 3月 25 22:17:19 2014

Copyright (c) 1982, 2010, Oracle. All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> set serveroutput on
SQL> @c:\pk\pro_wrap.plb

过程已创建。

SQL> exec pro_wrap;
Wrap Demo

PL/SQL 过程已成功完成。

通过exec测试,可看到存储过程执行成功。

4. 再验证下代码是否是加密了的.

SQL> set newpage none
SQL> set heading off
SQL> set space 0
SQL> set pagesize 0
SQL> set trimout on
SQL> set trimspool on
SQL> set linesize 2500
SQL> SELECT dbms_metadata.get_ddl('PROCEDURE','PRO_WRAP') FROM dual;

CREATE OR REPLACE PROCEDURE "SYS"."PRO_WRAP" wrapped
a000000
354
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
7
50 8d
cKb3/QEp0AIWOH/IyhxS2ffLbrUwg5nnm7+fMr2ywFwWFpfQlpbyVmmldIvAwDL+0oYJaWm4
UpuySv4osr3nsrMdBjAsriTqsoG4yGWcd2jPMi720eokHwKpyrXOpcrGpvY5pg2Gb0c=

可知确实是加密了的乱码。

linux

推荐阅读
author-avatar
月满西楼2502890155
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有