过程:
·在收费小型机Oracle系统的system用户(DBA)下,创建新用户test;
create user test
identified by carton
default tablespace dataspace1
quota 100K
·对test用户授以权限;
grant create session to test;
grant resource to test;
·在test用户下建立一个存储函数mmtranslate,它其实是一个加密程序。下面是一个简 单的例子。
function mmtranslate(m varchar2)
return varchar2
as
i number(2);
kk varchar2(10);
begin
kk:=′′;
i:=1;
loop
if i<=length(m) then
if instr(′1234567890′,substr(m,i,1),1,1)>0 then
kk:=kk||chr(100+to_number(substr(m,i,1)));
elseif instr(‘wxyz‘,substr(m,i,1),1,1)>0 then
kk:=kk||chr(-8+ascii(substr(m,i,1)));
else
kk:=kk||chr(4+ascii(substr(m,i,1)));
end if;
else
exit;
end if;
i:=i+1;
end loop;
return kk;
exception
when others then
return ′-1′;
end;
·在test用户下建表mmtest并插入记录:
create table mmtest
(usnamevarchar2(6),------用户名称
mimavarchar2(6)------加密前的密码);
insert into mmtest values( ‘sfyy‘,‘eds2‘);
commit;
·执行以下语句
SQL>select mmtranslate(‘eds2‘) from dual;
MMTRANSLATE(‘EDS2‘)
----------------------------------------
ihwf
利用DBA权限更改sfyy的密码为上面语句的执行结果:
alter user sffy
identified by ihwf; ;
·修改应用程序,对于开发环境是Develope2000的程序来说,主要是修改主程序的on-lo gon触发器:
declare
mm varchar2(6);
begin
logon(‘test‘,‘carton‘);
select mima into mm from mmtest where usname=‘sfyy‘;
mm:=mmtranslate(mm);
logout;
logon(‘sfyy‘,mm);
end;

