0drop trigger scjmmm.
create or replace trigger scjmmm
before insert or 0update of mm on ghxxb for each row
begin
:new.mm:=encrypt(:new.mm,:new.gh,to_char(sysdate,‘ss‘)).
end.
/
---------------------------密码的加密程序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.
/ |