ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORACLE应用经验(4)-加密程序

ORACLE应用经验(4)-加密程序

原创 Linux操作系统 作者:WebSnap 时间:2019-07-07 22:09:05 0 删除 编辑
ORACLE应用经验(4)-加密程序

-------------1. 加密程序数据库触发子scjmmm----------------------
REM 对GHXXB制立数据库触发子(当INSERT OR UPDATE GHXXB时触发)
drop trigger scjmmm;
create or replace trigger scjmmm
before insert or update of mm On ghxxb For each Row
Begin
:new.mm:=ENCRYPT(:new.mm,:NEW.GH,TO_CHAR(SYSDATE,'SS'));
End;
/
-------------2. 密码的加密程序ENCRYPT----------------------
Create or Replace
Function ENCRYPT (Inpass In Varchar2,IN_GH In Varchar2,IN_SS In Varchar2)
Return Varchar2 Is
bcs varchar2(20);
bcs1 number;
cs number;
jg number;
m_gh VARCHAR2(4);
m_mm VARCHAR2(20);
Begin
m_gh:=IN_GH;
m_mm:=INPASS;
cs:=TO_NUMBER(IN_SS);
If cs<=1 then cs:=77 ;end if;
bcs:=substr(to_char(ascii(substr(m_gh,1,1))),1,2);
If bcs<'1' then bcs:='7' ;end if;
m_gh:=substr(m_gh,2);
Loop EXIT WHEN nvl(length(m_gh),0)=0 ;
bcs:=bcs||substr(to_char(ascii(substr(m_gh,1,1))),-1,1);
m_gh:=substr(m_gh,2);
End loop;
Loop EXIT WHEN nvl(length(m_mm),0)=0 ;
bcs:=bcs||substr(to_char(ascii(substr(m_mm,1,1))),-1,1);
m_mm:=substr(m_mm,2);
End loop;
bcs1:=to_number(bcs);
jg:=cs*bcs1;
Loop EXIT WHEN length(to_char(jg))>13;
jg:=jg*cs ;
End loop;
RETURN(IN_SS||substr(to_char(jg),1,14));
End;
/
grant execute on ENCRYPT to public;


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10797429/viewspace-101515/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    163
  • 访问量
    121765